InputBox not passing user input

jerryczarnowski

Registered User.
Local time
Yesterday, 20:24
Joined
Jan 29, 2012
Messages
31
Hello,

My intent is to prompt the user for a Cutter ID and utilize the InputBox to capture the user's input and pass it to a string variable representing a SQL statement, then run the SQL. When I run the code below, it asks me for a parameter value for CutterID right after the InputBox prompts me. Is the code below correct for my intent?

Private Sub cmdFindCutter_Click()

Dim CutterID As String
Dim Message As String
Dim CutterInfo As String

Message = "Enter Cutter ID"
CutterID = InputBox(Message)

CutterInfo = "SELECT * FROM [Abc_All_Cutters] WHERE [Abc_All_Cutters].[Cutting Tool ID] = CutterID "

DoCmd.OpenForm "UPMF_Cutters", , , , acHidden
Forms![UPMF_Cutters].RecordSource = CutterInfo
DoCmd.Restore

End Sub
 
If you do it this way CutterID need to be concatenated into the SQL like:

Code:
CutterInfo = "SELECT * FROM [Abc_All_Cutters] WHERE [Abc_All_Cutters].[Cutting Tool ID] = " &  CutterID

if [Cutting Tool ID] is numeric or

Code:
CutterInfo = "SELECT * FROM [Abc_All_Cutters] WHERE [Abc_All_Cutters].[Cutting Tool ID] = '" &  CutterID & "'"

if it is text.
 
Thanks Steve...it worked perfect
 

Users who are viewing this thread

Back
Top Bottom