Quick syntax error help

T

Tal

I have the following code on a form


Private Sub cboSearchDonor_AfterUpdate()
Dim strWhere As String
Const strcStub = "SELECT * FROM qryClientsandClientAddresses "

If Not IsNull(Me.cboSearchDonor) Then
strWhere = "WHERE (tblClients.keyClient = " & Me.cboSearchDonor & ")"
End If
Forms![frmEditDonors].RecordSource = strcStub & strWhere

Dim strAddress As String
strAddress = "SELECT [qryClientsandClientAddresses].[keyClientAddress],
[qryClientsandClientAddresses].[compAddress] " & _
"FROM qryClientsandClientAddresses " & _
"WHERE [qryClientsandClientAddresses].[tblClients.keyClient] = " &
Me.cboSearchDonor.Value
Me.cboSelectAddress.RowSource = strAddress
Me.cboSelectAddress.Requery

End Sub

The first part is fine, the record source is working, except select
cboSelectAddress is giving me the syntax error missing operator error. I have
used this code any number of times, so I am feeling pretty darn foolish. Any
help much much appreciated.

Cheers,
Tal
 
S

Steve Sanford

"WHERE [qryClientsandClientAddresses].[tblClients.keyClient] = " &

AFAIK, you cannot have a field name with a dot (".") in it.
Shouldn't the above "WHERE" clause be something like:


"WHERE [qryClientsandClientAddresses].[keyClient] = " &

(removed "tblClients.")


HTH
--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)


Tal said:
I have the following code on a form


Private Sub cboSearchDonor_AfterUpdate()
Dim strWhere As String
Const strcStub = "SELECT * FROM qryClientsandClientAddresses "

If Not IsNull(Me.cboSearchDonor) Then
strWhere = "WHERE (tblClients.keyClient = " & Me.cboSearchDonor & ")"
End If
Forms![frmEditDonors].RecordSource = strcStub & strWhere

Dim strAddress As String
strAddress = "SELECT [qryClientsandClientAddresses].[keyClientAddress],
[qryClientsandClientAddresses].[compAddress] " & _
"FROM qryClientsandClientAddresses " & _
"WHERE [qryClientsandClientAddresses].[tblClients.keyClient] = " &
Me.cboSearchDonor.Value
Me.cboSelectAddress.RowSource = strAddress
Me.cboSelectAddress.Requery

End Sub

The first part is fine, the record source is working, except select
cboSelectAddress is giving me the syntax error missing operator error. I have
used this code any number of times, so I am feeling pretty darn foolish. Any
help much much appreciated.

Cheers,
Tal
 
T

Tal

Hi Steve,

Thank you for the response. Actually, as soon as I moved the code to the
LostFocus event, it worked.
Sometimes ours is not to question, but to nod, smile and move on to the next
conundrum.

Steve Sanford said:
"WHERE [qryClientsandClientAddresses].[tblClients.keyClient] = " &

AFAIK, you cannot have a field name with a dot (".") in it.
Shouldn't the above "WHERE" clause be something like:


"WHERE [qryClientsandClientAddresses].[keyClient] = " &

(removed "tblClients.")


HTH
--
Steve S
--------------------------------
"Veni, Vidi, Velcro"
(I came; I saw; I stuck around.)


Tal said:
I have the following code on a form


Private Sub cboSearchDonor_AfterUpdate()
Dim strWhere As String
Const strcStub = "SELECT * FROM qryClientsandClientAddresses "

If Not IsNull(Me.cboSearchDonor) Then
strWhere = "WHERE (tblClients.keyClient = " & Me.cboSearchDonor & ")"
End If
Forms![frmEditDonors].RecordSource = strcStub & strWhere

Dim strAddress As String
strAddress = "SELECT [qryClientsandClientAddresses].[keyClientAddress],
[qryClientsandClientAddresses].[compAddress] " & _
"FROM qryClientsandClientAddresses " & _
"WHERE [qryClientsandClientAddresses].[tblClients.keyClient] = " &
Me.cboSearchDonor.Value
Me.cboSelectAddress.RowSource = strAddress
Me.cboSelectAddress.Requery

End Sub

The first part is fine, the record source is working, except select
cboSelectAddress is giving me the syntax error missing operator error. I have
used this code any number of times, so I am feeling pretty darn foolish. Any
help much much appreciated.

Cheers,
Tal
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top