Hi there,
I'm new to this forum and I hope someone will be able to help. I've built a search form and a query that looks for data in a lessons learned database called LLIS. I've attached a screenshot of the form.
I've designed the query so that you can choose one or more fields and make your own search criteria.
As an axample the row source for the Field Name combo box is:
SELECT DISTINCT LLIS.[Field Name] FROM LLIS ORDER BY LLIS.[Field Name];
What I would like is a cascading query meaning that when I choose a specific Field, the number of wells displayed in the Well Name combo will be limited to the ones related to the specific field chosen... and that is not a problem, that part works. I use a following code on After Update (example from Field Name combo limiting choices on Well Name):
Private Sub CBFieldName_AfterUpdate()
On Error Resume Next
CbWellName.RowSource = "Select distinct LLIS.[Well Name] " & _
"FROM LLIS " & _
"WHERE LLIS.[Field Name] = '" & CBFieldName & "' " & _
"ORDER BY LLIS.[Well Name]"
End Sub
My problem is that I'd like to be able to see all Well Names if the Field Name combo is left blank... and all Sections if the Field Name & Well Name combos are left blank ... and so on. I don't know how to design that condition and where to place it,.. on which event?
I'm new to Access and not a VBA expert. I'd appreciate your help on this!
Thanks in advance,
Michal
I'm new to this forum and I hope someone will be able to help. I've built a search form and a query that looks for data in a lessons learned database called LLIS. I've attached a screenshot of the form.
I've designed the query so that you can choose one or more fields and make your own search criteria.
As an axample the row source for the Field Name combo box is:
SELECT DISTINCT LLIS.[Field Name] FROM LLIS ORDER BY LLIS.[Field Name];
What I would like is a cascading query meaning that when I choose a specific Field, the number of wells displayed in the Well Name combo will be limited to the ones related to the specific field chosen... and that is not a problem, that part works. I use a following code on After Update (example from Field Name combo limiting choices on Well Name):
Private Sub CBFieldName_AfterUpdate()
On Error Resume Next
CbWellName.RowSource = "Select distinct LLIS.[Well Name] " & _
"FROM LLIS " & _
"WHERE LLIS.[Field Name] = '" & CBFieldName & "' " & _
"ORDER BY LLIS.[Well Name]"
End Sub
My problem is that I'd like to be able to see all Well Names if the Field Name combo is left blank... and all Sections if the Field Name & Well Name combos are left blank ... and so on. I don't know how to design that condition and where to place it,.. on which event?
I'm new to Access and not a VBA expert. I'd appreciate your help on this!
Thanks in advance,
Michal