By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,896 Members | 1,983 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,896 IT Pros & Developers. It's quick & easy.

After Update event asking for paramater value

P: 62
I have a form called f_Dashboard which has the following code on the AfterUpdate() event of an unbound field called SelectCityAllTrips. This code opens a filtered set of records in f_MainTripForm based on the value that the user enters in the SelectCityAllTrips field.

Expand|Select|Wrap|Line Numbers
  1. Private Sub SelectCityAllTrips_AfterUpdate()
  2. DoCmd.OpenForm "f_MainTripForm", , , "City = " & SelectCityAllTrips.value
  3. DoCmd.Close acForm, "f_Dashboard"
  4. End Sub
When the code runs, it opens an input form asking the user to enter a parameter value. See image

When you re-type the value here again, f_MainTripForm opens up with the correct records.

I am trying to bypass the parameter request and open the form directly.

I have several other unbound fields that work with similar code but they don't ask for a parameter value to be re-entered. The only difference is that the other fields use numberic values and this is a text field.

Any help appreciated.
Sandra

Attached Images
File Type: png example.png (15.4 KB, 247 views)
May 29 '12 #1

✓ answered by Rabbit

That's because string values need to be enclosed in quotes.
Expand|Select|Wrap|Line Numbers
  1. WHERE city = 'Chicago'
  2. WHERE city = Chicago
The first one if what you need. The second one is what you have.

Share this Question
Share on Google+
3 Replies


Rabbit
Expert Mod 10K+
P: 12,366
That's because string values need to be enclosed in quotes.
Expand|Select|Wrap|Line Numbers
  1. WHERE city = 'Chicago'
  2. WHERE city = Chicago
The first one if what you need. The second one is what you have.
May 29 '12 #2

P: 62
Thanks for the clue!

Here is the updated code:
Expand|Select|Wrap|Line Numbers
  1. Private Sub SelectCityAllTrips_AfterUpdate()
  2.  
  3. DoCmd.OpenForm "f_MainTripForm", , , "City = " & "'" & SelectCityAllTrips.value & "'"
  4. DoCmd.Close acForm, "f_Dashboard"
  5. End Sub
  6.  
Much appreciated!
May 29 '12 #3

NeoPa
Expert Mod 15k+
P: 31,491
Indeed. See Quotes (') and Double-Quotes (") - Where and When to use them.

Also, you don't need to concatenate (&) two separate literal strings on a single line. "City = " & "'" is no different from "City = '". Your code could be :
Expand|Select|Wrap|Line Numbers
  1. DoCmd.OpenForm "f_MainTripForm", , , "[City] = '" & SelectCityAllTrips & "'"
Jun 2 '12 #4

Post your reply

Sign in to post your reply or Sign up for a free account.