Hi all,
I'm trying to build an access form with a combobox that can search on multiple columns. I built it once and it was working as expected, then I changed the data source and it stopped working. I then tried building the old one from scratch.
There are three comboboxes that I'm using as a search function. I use the following columns (PK) Primary Key, Branch_Name, and Branch_Number.
The PK combobox works correctly, but when I select either of the other two options, they don't return the correct result. Is there something I did when recreating the form that cause the sources to get mixed up?
------------
I'm trying to build an access form with a combobox that can search on multiple columns. I built it once and it was working as expected, then I changed the data source and it stopped working. I then tried building the old one from scratch.
There are three comboboxes that I'm using as a search function. I use the following columns (PK) Primary Key, Branch_Name, and Branch_Number.
The PK combobox works correctly, but when I select either of the other two options, they don't return the correct result. Is there something I did when recreating the form that cause the sources to get mixed up?
------------
Code:
Option Compare Database
Private Sub cboPK_AfterUpdate()
Dim PK As String
PK = "Select * from dbo_CRA_Branch_Hours " & _
"where ([PK] = " & Me.cboPK & ")"
Me.dbo_CRA_Branch_Hours_subform.Form.RecordSource = PK
Me.dbo_CRA_Branch_Hours_subform.Form.Requery
End Sub
Private Sub cboBranchName_AfterUpdate()
Dim Branchname As String
Branchname = "Select * from dbo_CRA_Branch_Hours " & _
"where ([Branch_Name] = '" & Me.cboBranchName & "')"
Me.dbo_CRA_Branch_Hours_subform.Form.RecordSource = Branchname
Me.dbo_CRA_Branch_Hours_subform.Form.Requery
End Sub
Private Sub cboBranchNumber_AfterUpdate()
Dim MyBranch_Number As String
MyBranch_Number = "Select * from dbo_CRA_Branch_Hours " & _
"where ([Branch_Number] = " & Me.cboBranchNumber & ")"
Me.dbo_CRA_Branch_Hours_subform.Form.RecordSource = MyBranch_Number
Me.dbo_CRA_Branch_Hours_subform.Form.Requery
End Sub
Comment