D
DeDBlanK
Hi,
I have to make a entry form for people that are not tech savy.
The route I am taking is to use a dialog with selectable parameters on
it. When the user clicks the button, I want the form to search for
the criteria from a table. If the criteria matches, open entry form
with that record. If there is no match, then open the entry form and
automatically input the search parameters.
Still new at VBA and recordsets with DAO.
Here is the code for the button on the dialog so far:
*************************CODE**************************
Private Sub cmdFindAdd_Click()
Dim strSQL As String
Dim dtmDate As Date
Dim lngLine As Long
Dim lngShift As Long
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim blnFound As Boolean
Dim fldItem As DAO.Field
'Set bolean to false, used for verfying if record is found
blnFound = False
'If any criteria is missing end Sub
If Me.cmbDate = "" Or Me.cmbLine = "" Or Me.cmbShift = "" Then
Exit Sub
Set db = CurrentDb()
Set rs = New DAO.Recordset
Set strSQL = "SELECT * FROM tblProductionDate WHERE lngLineId = "
& Me.cmbLine & ", lngShift = " & Me.cmbShift & ", dtmDate = " &
Me.cmbDate & ";"
rs.OpenRecordset strSQL
With rstStoreItems
While Not .EOF
************************END CODE************************************
That's where I am stuck. Not quite sure where to go or if what I have
will even work. Looked around the web for something like what I am
asking, but really couldn't find a lot to show me how to call a
recordset from another table and then pull the Primary key over to the
entry form.
However, I think I could handle the code for inputting the parameter
data to the entry form on new record.
Something like:
Docmd.openform frmProdMain,,,NewRecord
dtmDate.value=cmbDate, lngLine.value=cmbLine,
lngShift.value=cmbShift ???
Guess my brain is just not working today =(
If anyone knows how I can accomplish this or has a better idea, I
would greatly appreciate it.
Thanks!
I have to make a entry form for people that are not tech savy.
The route I am taking is to use a dialog with selectable parameters on
it. When the user clicks the button, I want the form to search for
the criteria from a table. If the criteria matches, open entry form
with that record. If there is no match, then open the entry form and
automatically input the search parameters.
Still new at VBA and recordsets with DAO.
Here is the code for the button on the dialog so far:
*************************CODE**************************
Private Sub cmdFindAdd_Click()
Dim strSQL As String
Dim dtmDate As Date
Dim lngLine As Long
Dim lngShift As Long
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim blnFound As Boolean
Dim fldItem As DAO.Field
'Set bolean to false, used for verfying if record is found
blnFound = False
'If any criteria is missing end Sub
If Me.cmbDate = "" Or Me.cmbLine = "" Or Me.cmbShift = "" Then
Exit Sub
Set db = CurrentDb()
Set rs = New DAO.Recordset
Set strSQL = "SELECT * FROM tblProductionDate WHERE lngLineId = "
& Me.cmbLine & ", lngShift = " & Me.cmbShift & ", dtmDate = " &
Me.cmbDate & ";"
rs.OpenRecordset strSQL
With rstStoreItems
While Not .EOF
************************END CODE************************************
That's where I am stuck. Not quite sure where to go or if what I have
will even work. Looked around the web for something like what I am
asking, but really couldn't find a lot to show me how to call a
recordset from another table and then pull the Primary key over to the
entry form.
However, I think I could handle the code for inputting the parameter
data to the entry form on new record.
Something like:
Docmd.openform frmProdMain,,,NewRecord
dtmDate.value=cmbDate, lngLine.value=cmbLine,
lngShift.value=cmbShift ???
Guess my brain is just not working today =(
If anyone knows how I can accomplish this or has a better idea, I
would greatly appreciate it.
Thanks!