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

code building...

P: 3
how do i build up the code if this are the following commands i would want to execute.

i have a few drop down lists. when i select any of the drop down, n click on OK, it should open up a query. the query has a criteria of eg.[forms]![fil_records]![noc_date].

I wanted to build up a code such that when the users click onto OK, if the 1st dropdown is not selected it will go on to the next one, or else if it has been selected, it will open up the query associated. However, there shouldn't be any window appearing to ask for the parameter value for the queries. It should be associated with the drop down such that the value selected will be the parameter value for the query.
May 15 '07 #1
Share this Question
Share on Google+
3 Replies


Rabbit
Expert Mod 10K+
P: 12,350
I'm not sure I understand completely, you just want to open up a query depending on the first non-null combo box?

Just use an If/Then/ElseIf Not IsNull() structure.
May 17 '07 #2

puppydogbuddy
Expert 100+
P: 1,923
Here is example of code building for a where clause used to filter a report.
Expand|Select|Wrap|Line Numbers
  1. strFilter = ""
  2. If Not IsNull(Me!combo1) Then strFilter = strFilter & "[fld1]=" & Chr(34) & Me!combo1 & Chr(34) & " AND "
  3. If Not IsNull(Me!combo2) Then strFilter = strFilter & "[fld2]=" & Chr(34) & Me!combo2 & Chr(34) & " AND "
  4. If Not IsNull(Me!combo3) Then strFilter = strFilter & "[fld3]=" & Chr(34) & Me!combo3 & Chr(34) & " AND "
  5.  
  6. If strFilter <> "" Then
  7.     strFilter = Left$(strFilter, Len(strFilter) - 5)
  8.     Me.Filter = strFilter
  9.     Me.FilterOn = True
  10.  
  11.     Me.Requery
  12.     DoCmd.OpenReport strReport, acViewPreview, , strFilter
  13.  
  14. End If
  15.  
Jun 2 '07 #3

JConsulting
Expert 100+
P: 603
how do i build up the code if this are the following commands i would want to execute.

i have a few drop down lists. when i select any of the drop down, n click on OK, it should open up a query. the query has a criteria of eg.[forms]![fil_records]![noc_date].

I wanted to build up a code such that when the users click onto OK, if the 1st dropdown is not selected it will go on to the next one, or else if it has been selected, it will open up the query associated. However, there shouldn't be any window appearing to ask for the parameter value for the queries. It should be associated with the drop down such that the value selected will be the parameter value for the query.

if it's in the field criteria in your query use this format

iif(nz([forms]![fil_records]![noc_date],0)=0,[noc_date],[forms]![fil_records]![noc_date])

J
Jun 2 '07 #4

Post your reply

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