O
Olu Solaru
Scenario - I have form that contains one combo box, twelve text boxes and
two command buttons.
The combo box upon selection, automatically populates the text boxes with
the data. One command button(cmdSumbit) adds the data in the text boxes to
a table, and the other closes the form (cmdClose).
Want I want to do is to generate a report based on the me clicking the
cmdSubmit button. This way in addition to adding the data in the textboxes
to a table, I would also like to be able to generate a report based on the
contents of those textboxes.
Basically running two events with one click. Below is a code for my
cmdSubmit button. Where within this code, will I place the procedure to run
a report.
Private Sub cmdSubmit_Click()
On Error GoTo Err_cmdSubmit_Click
Dim rstOrder As ADODB.Recordset
Set rstOrder = New ADODB.Recordset
rstOrder.Open "tblLotNumber", CurrentProject.Connection,
adOpenStatic, adLockOptimistic
If rstOrder.Supports(adAddNew) Then
With rstOrder
.AddNew
.Fields("BPRNumber") = cboBpr
.Fields("ProcessDate") = ProcessDate
.Fields("LotNumber") = LotNumber
.Fields("Sop1") = Sop1
.Fields("Sop2") = Sop2
.Fields("Sop3") = Sop3
.Fields("Sop4") = Sop4
.Fields("Sop5") = Sop5
.Fields("Sop6") = Sop6
.Fields("Sop7") = Sop7
.Fields("Sop8") = Sop8
.Fields("Sop9") = Sop9
.Fields("Sop10") = Sop10
.Fields("Sop11") = Sop11
.Fields("Sop12") = Sop12
.Fields("Sop13") = Sop13
.Fields("Sop14") = Sop14
.Fields("Sop15") = Sop15
.Fields("Sop16") = Sop16
.Update
'cmdReset_Click
End With
End If
rstOrder.Close
Set rstOrder = Nothing
' DoCmd.Close
Exit_cmdSubmit_Click:
Exit Sub
Err_cmdSubmit_Click:
MsgBox Err.Description
Resume Exit_cmdSubmit_Click
End Sub
two command buttons.
The combo box upon selection, automatically populates the text boxes with
the data. One command button(cmdSumbit) adds the data in the text boxes to
a table, and the other closes the form (cmdClose).
Want I want to do is to generate a report based on the me clicking the
cmdSubmit button. This way in addition to adding the data in the textboxes
to a table, I would also like to be able to generate a report based on the
contents of those textboxes.
Basically running two events with one click. Below is a code for my
cmdSubmit button. Where within this code, will I place the procedure to run
a report.
Private Sub cmdSubmit_Click()
On Error GoTo Err_cmdSubmit_Click
Dim rstOrder As ADODB.Recordset
Set rstOrder = New ADODB.Recordset
rstOrder.Open "tblLotNumber", CurrentProject.Connection,
adOpenStatic, adLockOptimistic
If rstOrder.Supports(adAddNew) Then
With rstOrder
.AddNew
.Fields("BPRNumber") = cboBpr
.Fields("ProcessDate") = ProcessDate
.Fields("LotNumber") = LotNumber
.Fields("Sop1") = Sop1
.Fields("Sop2") = Sop2
.Fields("Sop3") = Sop3
.Fields("Sop4") = Sop4
.Fields("Sop5") = Sop5
.Fields("Sop6") = Sop6
.Fields("Sop7") = Sop7
.Fields("Sop8") = Sop8
.Fields("Sop9") = Sop9
.Fields("Sop10") = Sop10
.Fields("Sop11") = Sop11
.Fields("Sop12") = Sop12
.Fields("Sop13") = Sop13
.Fields("Sop14") = Sop14
.Fields("Sop15") = Sop15
.Fields("Sop16") = Sop16
.Update
'cmdReset_Click
End With
End If
rstOrder.Close
Set rstOrder = Nothing
' DoCmd.Close
Exit_cmdSubmit_Click:
Exit Sub
Err_cmdSubmit_Click:
MsgBox Err.Description
Resume Exit_cmdSubmit_Click
End Sub