gamesprite
New member
- Local time
- Today, 09:00
- Joined
- Sep 19, 2019
- Messages
- 3
Everytime I try to place a SQL query in VBA, it doesn't work. I can create queries in the RowSource of ComboBoxes but I cannot get them to work in my code. I have a uniform and PPE database to keep track of issues to employees. I am using 3 cascading comboboxes to help user select the proper clothing item. The first box contains the clothing catagory: work, dress, ppe, and accesories, the second box contains the specific types of items eg: button down shirts, coveralls, etc. The third contains the sizes of the items. I have disabled the second two until the first one is choose. I have a form that shows the the title of the page. Control Source: =[Caption]. Each form has a Caption. Any way, when I run the code, the title says #Error"
txtType and txtPrimary are the first and second ComboBoxes
Primary_Num and Item_Num are actually strings
The code is :
Private Sub txtType_AfterUpdate()
'On Error Resume Next I had this uncommented at first
strSQL = "Select Primary.Item_Num, Primary.Item_Catagory, Primary.Primary_Num "&_
"From Primary " & _
"Where Primary.Primary_Num LIKE '" &m.txtType.Value &"';"
Me.txtPrimary.RowSource = strSQL
Me.txtPrimary.Requery
I am not getting an Error but it shows up in the title
txtType and txtPrimary are the first and second ComboBoxes
Primary_Num and Item_Num are actually strings
The code is :
Private Sub txtType_AfterUpdate()
'On Error Resume Next I had this uncommented at first
strSQL = "Select Primary.Item_Num, Primary.Item_Catagory, Primary.Primary_Num "&_
"From Primary " & _
"Where Primary.Primary_Num LIKE '" &m.txtType.Value &"';"
Me.txtPrimary.RowSource = strSQL
Me.txtPrimary.Requery
I am not getting an Error but it shows up in the title