Help building query for use in ado recordset

Prysson

Registered User.
Local time
Today, 20:25
Joined
Sep 23, 2002
Messages
45
Could someone double check my query expression below. Something is not right I know but I cant figure out what it is. I think it is a part of the And tblArea.Location = [Forms]![frmSelectLocationStartDefault]![cmbLocation] but I cant be certain....Just an fyi that cmbloacation data type is numeric (autorecord).



Set rs = New ADODB.Recordset
Dim NodX As Node
Set strLocationName = Forms!frmSelectLocationStartDefault!cmbLocation

With rs
.ActiveConnection = CurrentProject.Connection
.CursorLocation = adUseServer
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Open "SELECT * FROM tblArea WHERE tblArea.AreaName <> 'na' And tblArea.LocationID = [Forms]![frmSelectLocationStartDefault]![cmbLocation] ORDER BY tblArea.AreaName;"

End With
 
Maybe try Forms!frmSelectLocationStartDefault.Form!cmbLocation
 
I just resolved it

.Open "SELECT * FROM tblArea WHERE tblArea.AreaName <> 'na' And tblArea.LocationID = " & [Forms]![frmSelectLocationStartDefault]![cmbLocation] & " ORDER BY tblArea.AreaName;"

I needed the & in the statement
 

Users who are viewing this thread

Back
Top Bottom