473,396 Members | 1,938 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 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 3659
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 current document? I need to do all this in script...
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 some select fields in a form I created for a...
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 the form I want when the user types in the VendNo...
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 populate once a selection is chosen. A related...
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 I might not find the record. example: if I am...
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, and the training histories are stored in...
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 this form. There are some buttons (like submit ,...
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 break out of a function when a button push occurs. ...
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 checkbox the auto populate works well with texboxes...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.