Let me try to restate my problem.
A user opens the database and "main" form opens with a command button and three text boxes. The three text boxes are: Shift, Start Date, and Stop Date.
Upon clicking the command button, input boxes open to allow the user to enter values for each of the three text boxes. After the third text box value is entered, the VBA code opens and runs a number of queries.
How can I use the values in the text boxes as criteria for the queries?
For example:
When the user enters the Start Date (with similar code for Stop Date (pdate2&3)):
pdate = InputBox("enter Production Start Date")
pdate = Format(pdate, shortdate)
pdate1 = Format(DateAdd("d", 1, pdate), shortdate)
If IsDate(pdate) Then
pdate = pdate
pdateyy = Format(pdate, "yyyymmdd")
pdate1 = pdate1
pdate1yy = Format(pdate, "yyyymmdd")
Else
pdate = Format(DateAdd("d", -1, Now()), shortdate)
pdate1 = Format(DateAdd("d", 1, Now()), shortdate)
pdateyy = Format(pdate, "yyyymmdd")
pdate1yy = Format(pdate, "yyyymmdd")
End If
txtStart.SetFocus
txtStart.Text = pdate
I want to use this as criteria :
>=([forms]![main]![pdate]) And <=([forms]![main]![pdate2])
>=([forms]![main]![pdate1]) And <=([forms]![main]![pdate3])
Is there a better way?
My queries are not recognizing "pdate" and are creating blank tables.
!!!!
A user opens the database and "main" form opens with a command button and three text boxes. The three text boxes are: Shift, Start Date, and Stop Date.
Upon clicking the command button, input boxes open to allow the user to enter values for each of the three text boxes. After the third text box value is entered, the VBA code opens and runs a number of queries.
How can I use the values in the text boxes as criteria for the queries?
For example:
When the user enters the Start Date (with similar code for Stop Date (pdate2&3)):
pdate = InputBox("enter Production Start Date")
pdate = Format(pdate, shortdate)
pdate1 = Format(DateAdd("d", 1, pdate), shortdate)
If IsDate(pdate) Then
pdate = pdate
pdateyy = Format(pdate, "yyyymmdd")
pdate1 = pdate1
pdate1yy = Format(pdate, "yyyymmdd")
Else
pdate = Format(DateAdd("d", -1, Now()), shortdate)
pdate1 = Format(DateAdd("d", 1, Now()), shortdate)
pdateyy = Format(pdate, "yyyymmdd")
pdate1yy = Format(pdate, "yyyymmdd")
End If
txtStart.SetFocus
txtStart.Text = pdate
I want to use this as criteria :
>=([forms]![main]![pdate]) And <=([forms]![main]![pdate2])
>=([forms]![main]![pdate1]) And <=([forms]![main]![pdate3])
Is there a better way?
My queries are not recognizing "pdate" and are creating blank tables.
!!!!