Data on 1 Form to display on another

rexb

Registered User.
Local time
Today, 13:27
Joined
Oct 29, 2008
Messages
129
Hello,

I have 2 forms, both are data entry forms only a few minor difference. What I want is to have the data on the 1st form display on the 2nd form (not necessarily all the data).

The 2nd form is opened once I click on a button. When it is clicked I would like to display the current records on the 1st form to display on the 2nd form.

How do I do this? Can anybody help me please.

Thank you.
 
I'm not sure what you mean. A tab control does not affect the syntax for referencing controls.
 
Well just thought maybe that is what's causing my error when I tried your suggestion.

I tried playing around now I think I am on the right track, the only problem is "Enter Parameter Value" box display and when I type in the Vehicle Id. the record displays. What I want is once I click on the Maintenance button below it will go directly to record which contains vehicle id, ehs# VIN and plate #. I've attached my form for you to see.

Thank you very much.
 

Attachments

  • problem1.JPG
    problem1.JPG
    79.9 KB · Views: 129
Is the frmInventoryMain still open? It needs to be.
 
How do I check if it's still open :) (not sure how)
 
What code or macro is behind the button that opens the 2nd form?
 
Last edited:
Private Sub btnVehicleMaintenance_Click()
DoCmd.OpenForm "frmVehicleMaintenance", , , "txtbox_VehicleId = '" & [Form]![frmInventoryMain].[txtbox_VehicleId] & "'"
End Sub

This is all that's on the event procedure
 
If VehicleID is a number, you dont need the quotes. By putting the quotes, you are telling Access that the value of txtbox_VehicleID is a string.

Should just be:
Code:
Private Sub btnVehicleMaintenance_Click()
DoCmd.OpenForm "frmVehicleMaintenance", , , "txtbox_VehicleId = " & [Form]![frmInventoryMain].[txtbox_VehicleId] 
End Sub
 
If VehicleID is a number, you dont need the quotes. By putting the quotes, you are telling Access that the value of txtbox_VehicleID is a string.

Should just be:
Code:
Private Sub btnVehicleMaintenance_Click()
DoCmd.OpenForm "frmVehicleMaintenance", , , "txtbox_VehicleId = " & [Form]![frmInventoryMain].[txtbox_VehicleId] 
End Sub


When I tried that I get
Run-time error '2465':
Microsoft Office Access can't find the field 'frmInventoryMain' referred to in your expression.
 
If this is executing from the frmInventoryMain form then all you need is:
Code:
Private Sub btnVehicleMaintenance_Click()
   DoCmd.OpenForm "frmVehicleMaintenance", , , "txtbox_VehicleId = '" & Me.txtbox_VehicleId & "'"
End Sub
 
When I tried that I get
Run-time error '2465':
Microsoft Office Access can't find the field 'frmInventoryMain' referred to in your expression.


My bad...should of been:
[Form]![frmInventoryMain]![txtbox_VehicleId]

But as RuralGuy said, you can use me.txtbox_vehicleID
 
Actually the syntax uses the Forms collestion so it should read:
[FORMS]![frmInventoryMain]![txtbox_VehicleId]
 
If I use this
1. DoCmd.OpenForm "frmVehicleMaintenance", , , "txtbox_VehicleId" = " & [Forms]![frmInventoryMain]![txtborx_VehicleId] &" '"

or this

2. DoCmd.OpenForm "frmVehicleMaintenance", , , "VehicleId" = " & me.txtborx_VehicleId "

The 2nd form shows up but with out the data.
 
I tried this

DoCmd.OpenForm "frmVehicleMaintenance", , , "txtbox_VehicleId" = " & [Forms]![frmInventoryMain]![txtborx_VehicleId] &" '"

and this

'DoCmd.OpenForm "frmVehicleMaintenance", , , "VehicleId" = " & me.txtborx_VehicleId "

The 2nd form now shows up but there is no data. Any suggestions?

Thank you
 
Has the record in the 1st form been saved yet? Is it even available for the second form to display?
 
Has the record in the 1st form been saved yet? Is it even available for the second form to display?


Yes it has been saved, actually I already have 3 records on the first form.
 
I tried this

DoCmd.OpenForm "frmVehicleMaintenance", , , "txtbox_VehicleId" = " & [Forms]![frmInventoryMain]![txtborx_VehicleId] &" '"

and this

'DoCmd.OpenForm "frmVehicleMaintenance", , , "VehicleId" = " & me.txtborx_VehicleId "

The 2nd form now shows up but there is no data. Any suggestions?

Thank you

You are using the quotes wrong. I am assuming that VehicleID is a number...in which case:

Code:
DoCmd.OpenForm "frmVehicleMaintenance", , , "VehicleId" = " & me.txtborx_VehicleId "

should be:
Code:
'DoCmd.OpenForm "frmVehicleMaintenance", , , "VehicleId" =  & me.txtborx_VehicleId
 

Users who are viewing this thread

Back
Top Bottom