Syntax error (missing operator) in query expression

P

Peter

Hi all and thanks for all help, i have this issue:

I have created a command button with the help of the command button wizard.
The purpose is to open a form and find a specific record related to the
textfield in the form i placed the commadn button: Case ID <> Case ID. The
form that resides the record is a single form. When i populate the textfiled
and press the button, the form opens with the correct record but if i press
the command button and the textfield is empty i receive the following error
message:
Syntax error (missing operator) in query expression "[Case ID]= "

this is the code:

stLinkCriteria = "[Case ID]=" & Me![Case ID]

What am i doing wrong??????
 
J

Jeanette Cunningham

Hi Peter,
You stop the code from running if the textfield is empty like this-->
If Not IsNull(Me.CaseID) Then
stLinkCriteria = "[Case ID]=" & Me![Case ID]
End If

The code on the button will only run when there is something in textfield
and you won't see the error message.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia
 
P

Peter

Hi Jeanette, thank you for your assistance, however is am still doing
somehting very wrong apperantly since i recevie "compile Error"...datamemeber
not found..

Private Sub Finde_Case_ID_From_Menu_Click()
On Error GoTo Err_Finde_Case_ID_From_Menu_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Single View"


If Not IsNull(Me.CaseID) Then
stLinkCriteria = "[Case ID]=" & Me![Case ID]
End If


Exit_Finde_Case_ID_From_Menu_Click:
Exit Sub

Err_Finde_Case_ID_From_Menu_Click:
MsgBox Err.Description
Resume Exit_Finde_Case_ID_From_Menu_Click

End Sub

Jeanette Cunningham said:
Hi Peter,
You stop the code from running if the textfield is empty like this-->
If Not IsNull(Me.CaseID) Then
stLinkCriteria = "[Case ID]=" & Me![Case ID]
End If

The code on the button will only run when there is something in textfield
and you won't see the error message.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Peter said:
Hi all and thanks for all help, i have this issue:

I have created a command button with the help of the command button
wizard.
The purpose is to open a form and find a specific record related to the
textfield in the form i placed the commadn button: Case ID <> Case ID. The
form that resides the record is a single form. When i populate the
textfiled
and press the button, the form opens with the correct record but if i
press
the command button and the textfield is empty i receive the following
error
message:
Syntax error (missing operator) in query expression "[Case ID]= "

this is the code:

stLinkCriteria = "[Case ID]=" & Me![Case ID]

What am i doing wrong??????
 
J

Jeanette Cunningham

Peter,
It looks like your form has a name with a space in it.
"Single View"
Put square brackets around any form, query, table, or report names when
using them in VBA code

stDocName = "[Single View]"


If you are in the early stages of this database, I strongly suggest that you
use names that don't have any spaces or any odd characters in them.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Peter said:
Hi Jeanette, thank you for your assistance, however is am still doing
somehting very wrong apperantly since i recevie "compile
Error"...datamemeber
not found..

Private Sub Finde_Case_ID_From_Menu_Click()
On Error GoTo Err_Finde_Case_ID_From_Menu_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Single View"


If Not IsNull(Me.CaseID) Then
stLinkCriteria = "[Case ID]=" & Me![Case ID]
End If


Exit_Finde_Case_ID_From_Menu_Click:
Exit Sub

Err_Finde_Case_ID_From_Menu_Click:
MsgBox Err.Description
Resume Exit_Finde_Case_ID_From_Menu_Click

End Sub

Jeanette Cunningham said:
Hi Peter,
You stop the code from running if the textfield is empty like this-->
If Not IsNull(Me.CaseID) Then
stLinkCriteria = "[Case ID]=" & Me![Case ID]
End If

The code on the button will only run when there is something in textfield
and you won't see the error message.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Peter said:
Hi all and thanks for all help, i have this issue:

I have created a command button with the help of the command button
wizard.
The purpose is to open a form and find a specific record related to the
textfield in the form i placed the commadn button: Case ID <> Case ID.
The
form that resides the record is a single form. When i populate the
textfiled
and press the button, the form opens with the correct record but if i
press
the command button and the textfield is empty i receive the following
error
message:
Syntax error (missing operator) in query expression "[Case ID]= "

this is the code:

stLinkCriteria = "[Case ID]=" & Me![Case ID]

What am i doing wrong??????
 
J

Jeanette Cunningham

Slight clarification about names.

Putting square brackets around names in VBA applies to any names that have
spaces or other odd characters such as punctuation marks, the ampersand etc.



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia



Jeanette Cunningham said:
Peter,
It looks like your form has a name with a space in it.
"Single View"
Put square brackets around any form, query, table, or report names when
using them in VBA code

stDocName = "[Single View]"


If you are in the early stages of this database, I strongly suggest that
you use names that don't have any spaces or any odd characters in them.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Peter said:
Hi Jeanette, thank you for your assistance, however is am still doing
somehting very wrong apperantly since i recevie "compile
Error"...datamemeber
not found..

Private Sub Finde_Case_ID_From_Menu_Click()
On Error GoTo Err_Finde_Case_ID_From_Menu_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Single View"


If Not IsNull(Me.CaseID) Then
stLinkCriteria = "[Case ID]=" & Me![Case ID]
End If


Exit_Finde_Case_ID_From_Menu_Click:
Exit Sub

Err_Finde_Case_ID_From_Menu_Click:
MsgBox Err.Description
Resume Exit_Finde_Case_ID_From_Menu_Click

End Sub

Jeanette Cunningham said:
Hi Peter,
You stop the code from running if the textfield is empty like this-->
If Not IsNull(Me.CaseID) Then
stLinkCriteria = "[Case ID]=" & Me![Case ID]
End If

The code on the button will only run when there is something in
textfield
and you won't see the error message.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Hi all and thanks for all help, i have this issue:

I have created a command button with the help of the command button
wizard.
The purpose is to open a form and find a specific record related to
the
textfield in the form i placed the commadn button: Case ID <> Case ID.
The
form that resides the record is a single form. When i populate the
textfiled
and press the button, the form opens with the correct record but if i
press
the command button and the textfield is empty i receive the following
error
message:
Syntax error (missing operator) in query expression "[Case ID]= "

this is the code:

stLinkCriteria = "[Case ID]=" & Me![Case ID]

What am i doing wrong??????
 
P

Peter

Thanks Jeanette!

Jeanette Cunningham said:
Slight clarification about names.

Putting square brackets around names in VBA applies to any names that have
spaces or other odd characters such as punctuation marks, the ampersand etc.



Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia



Jeanette Cunningham said:
Peter,
It looks like your form has a name with a space in it.
"Single View"
Put square brackets around any form, query, table, or report names when
using them in VBA code

stDocName = "[Single View]"


If you are in the early stages of this database, I strongly suggest that
you use names that don't have any spaces or any odd characters in them.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Peter said:
Hi Jeanette, thank you for your assistance, however is am still doing
somehting very wrong apperantly since i recevie "compile
Error"...datamemeber
not found..

Private Sub Finde_Case_ID_From_Menu_Click()
On Error GoTo Err_Finde_Case_ID_From_Menu_Click

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "Single View"


If Not IsNull(Me.CaseID) Then
stLinkCriteria = "[Case ID]=" & Me![Case ID]
End If


Exit_Finde_Case_ID_From_Menu_Click:
Exit Sub

Err_Finde_Case_ID_From_Menu_Click:
MsgBox Err.Description
Resume Exit_Finde_Case_ID_From_Menu_Click

End Sub

:

Hi Peter,
You stop the code from running if the textfield is empty like this-->
If Not IsNull(Me.CaseID) Then
stLinkCriteria = "[Case ID]=" & Me![Case ID]
End If

The code on the button will only run when there is something in
textfield
and you won't see the error message.


Jeanette Cunningham MS Access MVP -- Melbourne Victoria Australia


Hi all and thanks for all help, i have this issue:

I have created a command button with the help of the command button
wizard.
The purpose is to open a form and find a specific record related to
the
textfield in the form i placed the commadn button: Case ID <> Case ID.
The
form that resides the record is a single form. When i populate the
textfiled
and press the button, the form opens with the correct record but if i
press
the command button and the textfield is empty i receive the following
error
message:
Syntax error (missing operator) in query expression "[Case ID]= "

this is the code:

stLinkCriteria = "[Case ID]=" & Me![Case ID]

What am i doing wrong??????
 

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