Reports

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Scenario: - I have a form that has one combo box, 12 text fields, and two
command buttons. -
Upon selection on my combo box, it auto-populates the 12 text fields.

One command button (cmdsubmit) automatically adds the records to the
corresponding table, and then clears the form. However what my boss wants is
that once the submit button is clicked, a report should generate based on the
contents of the 12 text fields. Is there a way to have the submit button do
two things at a time, my boss basically wants to the form as automated as
possible.

Can I add another procedure under the cmdsubmit object, like a
cmdsumbit_Mouseup(). Right now all I have is the cmdSubmit_Click()

Any clues will be appreciated.
 
Olu said:
Scenario: - I have a form that has one combo box, 12 text fields,
and two command buttons. -
Upon selection on my combo box, it auto-populates the 12 text fields.

One command button (cmdsubmit) automatically adds the records to the
corresponding table, and then clears the form. However what my boss
wants is that once the submit button is clicked, a report should
generate based on the contents of the 12 text fields. Is there a way
to have the submit button do two things at a time, my boss basically
wants to the form as automated as possible.

Can I add another procedure under the cmdsubmit object, like a
cmdsumbit_Mouseup(). Right now all I have is the cmdSubmit_Click()

Any clues will be appreciated.

The code behind one button can do as many things as you want it to including
calling other code routines and functions. Your code would basically look
like...

Sub ButtonName_Click

Lines of code to add data to table

Lines of code to run report

Lines of code to clear fields

End Sub
 
This is what my current code looks like, I just want to know where exactly I
wll add the code to run the reports, so that I do not cause a conflict with
my existing code -


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
 
You can add code to print the contents of the form, but you need to do this
before the data is sent to the final table. If you don't, then all the
values will not exist and can not be retrieved.

I am not sure what the purpose of printing out the values each time a form
in entered with values. To me this seems like a great waste of paper not to
mention that apparently the information is already somewhere else as you
call up the 12 fields with a combo box. Is your combo box calling from a
temp table or something?

Would it not be more prudent to print out any records that were added to the
table for that day rather than one by one. What you can do is add a date
field to the master table and set the default to be Date(). This will
automatically record the date the record was added. Then you can create a
query to print out all records that were added. On changed info, you would
need to write After Update code behind each field to change the date in the
master table for that record.

If you boss is still adamant about print off one record at a time, then have
the end-user just print that page and set the printing for selected record
before they click the submit button.
 
Those 12 text fields are training modules. The report I want to run will
basically give me all the employees who are trained on those modules.
 
Olu said:
This is what my current code looks like, I just want to know where
exactly I wll add the code to run the reports, so that I do not cause
a conflict with my existing code -

At the bottom right before...

Exit_cmdSubmit_Click:
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top