How to change the data source (RecordSource) Combo Box...?
I try to do this:
If Me.[Combo1] = "All books" Then
Forms![Form1]!Combo3.RecordSource = "Query1"
Else
Forms![Form1]!Combo3.RecordSource = "Query2"
End If
But it won't work…
How to change the data source (RecordSource) Combo Box...?
I try to do this:
If Me.[Combo1] = "All books" Then
Forms![Form1]!Combo3.RecordSource = "Query1"
Else
Forms![Form1]!Combo3.RecordSource = "Query2"
End If
But it won't work…
Make sure that your combo1 is returning the value you think it is, add a debug;
Code:Debug.Print Me.[Combo1] If Me.[Combo1] = "All books" Then Forms![Form1]!Combo3.RecordSource = "Query1" Else Forms![Form1]!Combo3.RecordSource = "Query2" End If
DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
Please use the star below the post to say thanks if we have helped !
↓↓ It's down here ↓↓
combos have rowsources, not recordsources
Since you are in the form module you can use the Me. keyword
Me.Combo3.rowsource = ...
If this helped, please click the star * at the bottom left and add to my reputation- Thanks
If Me.[Combo1] = "All books" Then
Me.Combo3.RowSource = "Query1"
Else
Me.Combo3.RowSource = "Query2"
End If
Not work...
Use this code. In addition to other errors, your error handler setup prevented the pertinent code from being in the execution path.
Code:Private Sub Combo1_AfterUpdate() On Error GoTo Error_Handler Me!Combo2.Enabled = True Me!Combo2 = "" If Me.[Combo1] = "All books" Then Me.Combo3.RowSource = "Query1" Me!Combo4.Visible = False Else Me.Combo3.RowSource = "Query2" End If Error_Handler_Exit: On Error Resume Next Exit Sub Error_Handler: Select Case Err Case Else MsgBox "Error " & Err.Number & " (" & Err.Description & ")", vbExclamation, "Error in Sub Combo1_AfterUpdate of Form_Form1" End Select Resume Error_Handler_Exit Resume End Sub
Hi Huron
Would suggest that the Form that opens on Startup is a better option.
You can PM me if you need further help.
Good Reading https://docs.microsoft.com/en-gb/off...on-description
"Not work" doesn't give us much to help you with.
What doesn't work?
Where have you put the code?
Does it run?
What do you have as the Row Source property of Combo3?
If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
Bob Fitzpatrick
Thank you very much... This code run properly...
You're welcome; and thanks for the star.
Please use # icon on toolbar when posting code snippets.
Cross Posting: https://www.excelguru.ca/content.php?184
Debugging Access: https://www.youtube.com/results?sear...bug+access+vba