Creating multiple records from one form (1 Viewer)

mike60smart

Registered User.
Local time
Today, 13:30
Joined
Aug 6, 2017
Messages
1,904
Hi
What is the SQL for the Command Button's ON Click Event to open the Report?
 

mike60smart

Registered User.
Local time
Today, 13:30
Joined
Aug 6, 2017
Messages
1,904
Yes the command button is set to open the report?
Yes we know this but if you can show us a screen shot of either the Macro or the On Click Event associated with the Button.
 

Atthe

Member
Local time
Today, 13:30
Joined
Oct 26, 2021
Messages
57
Yes we know this but if you can show us a screen shot of either the Macro or the On Click Event associated with the Button.
Sorry about that, see attached
 

Attachments

  • On click.png
    On click.png
    7.3 KB · Views: 105

mike60smart

Registered User.
Local time
Today, 13:30
Joined
Aug 6, 2017
Messages
1,904
Sorry about that, see attached
Hi

What you need is along these lines which would be the VB On Click Event of the Command Button.

In the Properties of the Command Button - select the Event Tab and then Click in the On Click Row

Next Click on the Elipse (...) at the end of the Row which will then display the Choose Builder.

Select Code Builder and Click OK

The following 2 lines will go in the Blank space between the Code as follows:-

Private Sub Command61_Click()
If Me.Dirty Then Me.Dirty = False

DoCmd.OpenReport "ReportName", acPreview, , "[RecID]=" & me.RecID

End Sub

You would need to replace "ReportName" with your Report Name and the Unique Identifier "RecID"




 

MajP

You've got your good things, and you've got mine.
Local time
Today, 08:30
Joined
May 21, 2018
Messages
8,527
As @mike60smart points out one of the easiest ways to open a form or report to a filter set of records is to do this with the docmd.openForm or docmd.openreport.

If your criteria is a string you need to surround with single quotes.
Docmd.openReport "ReportName", acPreview, , "[Assembly NumberSpec]='" & me.Assembly_NumberSpec & "'"

Also in the future do yourself a big favor and do not put any spaces or special characters in any field names or any other object names. If you have spaces you have to add special handling in all code and queries. The name always has to be in [square brackets]. Not required if no space. In vba the name gets an underscored added automatically.
 

Atthe

Member
Local time
Today, 13:30
Joined
Oct 26, 2021
Messages
57
As @mike60smart points out one of the easiest ways to open a form or report to a filter set of records is to do this with the docmd.openForm or docmd.openreport.

If your criteria is a string you need to surround with single quotes.
Docmd.openReport "ReportName", acPreview, , "[Assembly NumberSpec]='" & me.Assembly_NumberSpec & "'"

Also in the future do yourself a big favor and do not put any spaces or special characters in any field names or any other object names. If you have spaces you have to add special handling in all code and queries. The name always has to be in [square brackets]. Not required if no space. In vba the name gets an underscored added automatically.
Thanks for that.

Next on my list to implement is a system to manage the booking in & out of the tooling ie I would like a form where the user can choose what Tool Group to book out and where it is being booked out too and then be able to book the tooling back in and change the status field of each tooling within the group (So the user can record any damage that happened whilst the tooling was in use Is the best way to do this to add another table?

Also would like to be able to track when the tooling was in use at what time etc

Thank you for any pointers
 

Users who are viewing this thread

Top Bottom