By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,490 Members | 3,266 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,490 IT Pros & Developers. It's quick & easy.

Using a button to populate another form's auto# field.

P: n/a
I'm not certain if this made the post. Sorry if it's a repeat:

Using a Button to take an autonumber from one form to populate another
autonumber field on another form.

I have a Mainform "A" with a button and code that opens another Mainform
"B"
with a subform which has the same table as Mainform "A".

The button is supposed to tell the subform with the autonumber field
that
whatever appears there should be the same number In Mainform A.

How do I add code to my button, that opens Mainform B, and reach down
and
link to the its subform with the same populated autonumber field ?

This is the Open Form button code that I am using:

Private Sub Command116_Click()
On Error GoTo err_Command116_click
Dim stDocName As String
Dim stLinkCriteria As String
DoCmd.RunCommand acCmdSaveRecord

stDocName = "frmMain"
stLinkCriteria = "[txtGuestID]=" & Me![GuestID] 'BOTH ARE AUTONUMBER
FIELDS
DoCmd.OpenForm stDocName, , , stLinkCriteria
exit_Command116_click:
Exit Sub
err_Command116_click:
'MsgBox "Type/Select a 'Entry's Name', before clicking on
'Registration'."
Resume exit_Command116_click
End Sub

John

*** Sent via Developersdex http://www.developersdex.com ***
Nov 13 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
I must admit that I didn't finish reading your post to the end, because
the premise is not possible.

You can populate a NON-AUTONUMBER field on Form B with the autonumber
generated on Form A or you can Populate Form B with it's own Autonumber
when an Autonumber is generated on Form A but you can't synchronize two
Autonumbers in two different tables. That's the nature of Autonumbers ...
you cannot tell the table what they should be.

If you have your schema set up correctly, then you simply use a form-subform
arrangement where the LinkMaster and LinkChild properties are assigned to the
primary key of the master form ... like this ...

Form/Table: tblOrder with primary key of OrderID
Form/Table: tblOrderDetail with primary key of OrderDetailID
and foreign key of OrderID

Create a master form for Order and a subform for Order detail. Embed the
subform on the master form and set the LinkMaster and LinkChild properties
to OrderID. The population of the subform OrderID will be automatic, as will
the population of OrderDetailID if it's an Autonumber.
--

Danny J. Lesandrini
dl*********@hotmail.com
http://amazecreations.com/datafast/

"John Phelan-Cummings" <jp*********@hotmail.com> wrote in message news:3F*************@news.uswest.net...
I'm not certain if this made the post. Sorry if it's a repeat:

Using a Button to take an autonumber from one form to populate another
autonumber field on another form.

I have a Mainform "A" with a button and code that opens another Mainform
"B"
with a subform which has the same table as Mainform "A".

The button is supposed to tell the subform with the autonumber field
that
whatever appears there should be the same number In Mainform A.

How do I add code to my button, that opens Mainform B, and reach down
and
link to the its subform with the same populated autonumber field ?

This is the Open Form button code that I am using:

Private Sub Command116_Click()
On Error GoTo err_Command116_click
Dim stDocName As String
Dim stLinkCriteria As String
DoCmd.RunCommand acCmdSaveRecord

stDocName = "frmMain"
stLinkCriteria = "[txtGuestID]=" & Me![GuestID] 'BOTH ARE AUTONUMBER
FIELDS
DoCmd.OpenForm stDocName, , , stLinkCriteria
exit_Command116_click:
Exit Sub
err_Command116_click:
'MsgBox "Type/Select a 'Entry's Name', before clicking on
'Registration'."
Resume exit_Command116_click
End Sub

John

*** Sent via Developersdex http://www.developersdex.com ***

Nov 13 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.