Open Current Record on New Form

G

Guest

I have a form that users will input data. Once they are finished, they will
click a control and the data of the current record needs to be put into
controls on a different form that will open up.

I currently have the code:
DoCmd.OpenForm "Canal_PG4", , , "ID" = Me.ID, acFormEdit
DoCmd.OpenForm "Canal_PG3", , , "ID" = Me.ID, acFormEdit
DoCmd.OpenForm "Canal_PG2", , , "ID" = Me.ID, acFormEdit
 
M

missinglinq via AccessMonster.com

I'm confused about exactly what it is you're trying to do! You talk of
opening up a different form, but your posted code

DoCmd.OpenForm "Canal_PG4", , , "ID" = Me.ID, acFormEdit
DoCmd.OpenForm "Canal_PG3", , , "ID" = Me.ID, acFormEdit
DoCmd.OpenForm "Canal_PG2", , , "ID" = Me.ID, acFormEdit

is actully opening 3 different forms!

Are you trying to open a single form, and autofill a new record on the new
form with the data from the current record on the calling form?

Or are you trying to open a single form that already has a record that
matches the ID from the current record of the calling form?

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
 
G

Guest

Ha Ha...sorry I wasn't more clear on that.

Yes when the user inputs information, code will call the required forms.
Each of the called forms will need to pull information and put it into it's
controls. All coming from the same record.

Sorry to be confusing,

Chris
 
M

missinglinq via AccessMonster.com

Here's an example for one moving the data from current record of calling form
to new record on the called form:

In a module declare a Public variable for the fields to be copied i.e.

Public MyName As String
Public MyAddress As String
Public MyZip As String

This makes the variables available to the 2nd, 3rd and 4th forms.

Private Sub ButtonToOpen2ndForm_Click()

'Copy fields of current form to variables
MyName = Me.Name
MyAddress = Me.Address
MyZip = Me.Zip

'Go to a new form
DoCmd.OpenForm "2ndFormName", , , , acFormAdd

End Sub

In the code for the 2nd Form:

Private Sub Form_Current()
If Me.NewRecord Then
'Plug in old values to new record
Me.NewFormName.Value = MyName
Me.NewFormAddress.Value = MyAddress
Me.NewFormZip.Value = MyZip
End If
End Sub

--
There's ALWAYS more than one way to skin a cat!

Answers/posts based on Access 2000

Message posted via AccessMonster.com
 

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

Top