Running a query using a button - problem

A

Andy Roberts

I have a button which when clicks opens a form based on a selection in a
combo box - all works fine, except if I dont actually select anything in the
combo i get the following error message:-

Syntax error (missing operator) in query expression '[ClientID]='

I understand why I get the message but my question is how best to handle it?

--
Regards

Andy
___________
Andy Roberts
Win XP Pro
Access 2007
Liverpool, UK
 
G

Gina Whipp

One suggestion...

If Not IsNull(YourComboBox) Then
DoCmd.OpenForm "YourForm", , , "[ClientID]=" & Me![YourComboBox]
Else
MsgBox "You must select a Client first!", vbExclamation, "Select
Client"
DoCmd.CancelEvent
End If
 
A

Andy Roberts

Thanks Gina

Works perfectly

--
Regards

Andy
___________
Andy Roberts
Win XP Pro
Access 2007
Liverpool, UK
Gina Whipp said:
One suggestion...

If Not IsNull(YourComboBox) Then
DoCmd.OpenForm "YourForm", , , "[ClientID]=" & Me![YourComboBox]
Else
MsgBox "You must select a Client first!", vbExclamation, "Select
Client"
DoCmd.CancelEvent
End If


--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II
Andy Roberts said:
I have a button which when clicks opens a form based on a selection in a
combo box - all works fine, except if I dont actually select anything in
the combo i get the following error message:-

Syntax error (missing operator) in query expression '[ClientID]='

I understand why I get the message but my question is how best to handle
it?

--
Regards

Andy
___________
Andy Roberts
Win XP Pro
Access 2007
Liverpool, UK
 
G

Gina Whipp

Your welcome!

--
Gina Whipp

"I feel I have been denied critical, need to know, information!" - Tremors
II
Andy Roberts said:
Thanks Gina

Works perfectly

--
Regards

Andy
___________
Andy Roberts
Win XP Pro
Access 2007
Liverpool, UK
Gina Whipp said:
One suggestion...

If Not IsNull(YourComboBox) Then
DoCmd.OpenForm "YourForm", , , "[ClientID]=" & Me![YourComboBox]
Else
MsgBox "You must select a Client first!", vbExclamation, "Select
Client"
DoCmd.CancelEvent
End If


--
Gina Whipp

"I feel I have been denied critical, need to know, information!" -
Tremors II
Andy Roberts said:
I have a button which when clicks opens a form based on a selection in a
combo box - all works fine, except if I dont actually select anything in
the combo i get the following error message:-

Syntax error (missing operator) in query expression '[ClientID]='

I understand why I get the message but my question is how best to handle
it?

--
Regards

Andy
___________
Andy Roberts
Win XP Pro
Access 2007
Liverpool, UK
 

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

Similar Threads


Top