472,351 Members | 1,562 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,351 software developers and data experts.

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

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
1 3577
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Mike Dee | last post by:
Is it possible to dynamically create a new form object (form1), then create a new form field object and add it form1, and then add form1 to the...
7
by: Chuck Anderson | last post by:
I'm pretty much a JavaScript novice. I'm good at learning by example and changing those examples to suit my needs. That said .... ..... I have...
11
by: alphaomega3 | last post by:
I have a form called frmIlogEntry. this form is based on the table tblILOG. I have a fields in the table and on the form VendNo and VendName. On...
10
by: BNicholeN | last post by:
Hi I need to know how to get a form to auto populate, i.e. When I pick a city from Center Location, I would like the Operations Manger and SVP to...
2
by: buddyr | last post by:
Hello, I have a cmd button on form to search for serial number. I notice when I search for record-that if I don't start at the beginning of records...
1
by: kickergirl | last post by:
I have a database developed in MS Access 2000 that allows people to enter training histories for staff. The staff information is stored in tblStaff,...
1
by: ramel | last post by:
Hi all, I have a problem related to javascript , ajax and jsp. Please see this url http://xil.co.in/print_screen_2.JPG. I am working on...
5
by: andersond | last post by:
I probably didn't ask the question right; but, I have a webpage where agents are entering information about trucks they want insured. I want to...
5
tsubasa
by: tsubasa | last post by:
I have a form in ASP.net that has a checkbox option to auto populate the form with the user infomation that is held in an table. When I select the...
0
better678
by: better678 | last post by:
Question: Discuss your understanding of the Java platform. Is the statement "Java is interpreted" correct? Answer: Java is an object-oriented...
0
by: teenabhardwaj | last post by:
How would one discover a valid source for learning news, comfort, and help for engineering designs? Covering through piles of books takes a lot of...
1
by: Kemmylinns12 | last post by:
Blockchain technology has emerged as a transformative force in the business world, offering unprecedented opportunities for innovation and...
0
jalbright99669
by: jalbright99669 | last post by:
Am having a bit of a time with URL Rewrite. I need to incorporate http to https redirect with a reverse proxy. I have the URL Rewrite rules made...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: AndyPSV | last post by:
HOW CAN I CREATE AN AI with an .executable file that would suck all files in the folder and on my computerHOW CAN I CREATE AN AI with an .executable...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.