By Ken Getz, Paul Litwin, Andy Baron
Cover | Table of Contents | Colophon
[Type of Music?]
Type of Music?
Text
|
Query field
|
Data type
|
Control type
|
|---|
Public Function acbGetRandom(varFld As Variant) ' Though varFld isn't used, it's the only way to force the query ' to call this function for each and every row. Randomize acbGetRandom = Rnd End Function
acbGetRandom([State])
Between operator. For example, you have a table of
students and their grades, and a table of grade ranges and the
matching letter grade. Though there are lots of ways to solve this
problem with complex expressions and VBA, you know there must be a
solution involving just queries. You need a way to join these two
tables, finding matches when a value in the first table is between
two values in the second table.
=. To perform these types of joins, you must
specify the join in the criteria of the linking field.
SELECT Company, Address1, Address2, Address3, City, StateProvince, ZipPostalCode, Country FROM tblClients WHERE Country = "U.S.A."
<N/A>, which can be used to enter a null
value for the field. You don't want your users to be able to
enter all sorts of "garbage" entries, just
<N/A> (or some other special code).
<N/A> row to the row source for the combo
box. We suggest using <N/A> rather than
simply N/A to force the entry to sort to the top
of the combo box list. To make this work right, you'll need to
make the combo box unbound and use a bit of VBA code to move values
between the underlying table and the combo box.
<N/A> entry on
a form of your own, follow these steps:
|
Property
|
Value
|
|---|---|
|
Name
|
cboArtistID
|
|
ControlSource
|
Option
Compare
Binary statement in the declarations section of a
module to force VBA to make string comparisons that are
case-sensitive within the bounds of that module, but this affects
only string comparisons made in a VBA module, not comparisons made by
the Jet engine. Thus, even when you run the query from a VBA
Option
Compare
Binary procedure, any comparisons made in the
query are case-insensitive. The problem is that the Jet engine
doesn't know how to make case-sensitive string comparisons
using any of the standard query operators. Fortunately, you can
create your own case-sensitive string-comparison function in an
Option
Compare
Binary module and call this function from the
query. This solution shows you how to create the VBA function and how
to use it to perform case-sensitive searches.
|
FieldName
|
DataType
|
FieldSize
|
Index
|
|---|---|---|---|
|
ClientID
|
AutoNumber
|
Long Integer/Increment
|
Yes, primary key
|
Public Sub CreatePrmRst1( )
' Example of creating a recordset based on a parameter query.
' This example fails!
Dim db As DAO.Database
Dim rst As DAO.Recordset
Set db = CurrentDb( )
' Open the form to collect the parameters.
DoCmd.OpenForm "frmAlbumsPrm", , , , , acDialog
' OK was pressed, so create the recordset.
If IsFormOpen("frmAlbumsPrm") Then
' Attempt to create the recordset.
Set rst = db.OpenRecordset("qryAlbumsPrm")
rst.MoveLast
MsgBox "Recordset created with " & rst.RecordCount & _
" records.", vbOKOnly + vbInformation, "CreatePrmRst"
rst.Close
Else
' Cancel was pressed.
MsgBox "Query canceled!", vbOKOnly + vbCritical, _
"CreatePrmRst"
End If
DoCmd.Close acForm, "frmAlbumsPrm"
Set rst = Nothing
Set db = Nothing
End Sub
Option Compare Database Option Explicit Private Const conWhite = 16777215 Private Const conGray = -2147483633 Private Const conIndent = 2 Private Const conFlat = 0
Private Sub Form_KeyDown(KeyCode As Integer, Shift As Integer)
Select Case KeyCode
Case vbKeyPageUp, vbKeyPageDown
KeyCode = 0
Case Else
' Do nothing.
End Select
End Sub
|
Property
|
Value
|
|---|---|
|
RecordSource
|