I'm a new access programmer and I've been tasked with taking the old school index card / excel spreadsheet inventory system at work (an internship) and making an access database (because interns always get the "fun" jobs) Anyway, I say that other situations here are too complex because mine is really simple. My function follows as thus:
Public Function PartNumMod()
On Error GoTo Part_Number_Macro_Err
DoCmd.Requery "Subform1"
Forms!Subform1.SourceObject = Queries![Part Number Query]
Part_Number_Macro_Exit:
Exit Function
Part_Number_Macro_Err:
MsgBox Error$
Resume Part_Number_Macro_Exit
End Function
This function is called from a button on a form called Search form. Any help would be greatly appreciated.
SELECT Inventory.[PART NUMBER], Inventory.DESCRIPTION, Inventory.Location, Inventory.[B#9 Of], Inventory.[B#11 FM], Inventory.[B#14 DA], Inventory.[B#15 TL], Inventory.[B#16 WH], Inventory.[B#17 MH], Inventory.[B#22 TN], Inventory.[B#24], Inventory.QTY
FROM Inventory
WHERE (((Inventory.[PART NUMBER]) Like "*" & [Forms]![Search Form]![WhatPart] & "*"));
Here is part number query as requested.
Answers
I found the problem. I wasn't referencing things correctly. Following is my code, all prettied up and ready to see daylight.
'Tests to make sure that the subform isnt already loaded with the query
If Forms![Search Form]!Subform1.SourceObject <> "Query.Part Number Query" Then
'In theory, this should change the source of the subform to display the part number query
Forms![Search Form]!Subform1.SourceObject = "Query.Part Number Query"
End If
'Runs the requery on subform to refresh
DoCmd.Requery "Subform1"
So yeah. Resolution. Lets pray the boss likes it.
Thanks guys,
Santh