Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Making unbound control bound...

Status
Not open for further replies.

tdbeargrrl

Programmer
Feb 26, 2002
10
US
I think this is going to turn into a long description and I apologize for that in advance.

I have a form that is used for data entry. From this form several different supplimental forms are opened. (to enter address information etc, that does not apply on the main form). When a secondary form (NOT A SUBFORM) opens I am passing the (autonumber ID) from the main form to the secondary form. In addition to just being there on the form I would like this number to be stored in the table associated with the secondary form.

Not as long as I thought... Anyone have any suggestions. Am I too tired and missing the obvious...
 
If the supplemental table is linked to the main table, it should already have a Foreign key field in it. But from your description, it doesn't sound like it does.
I would like this number to be stored in the table associated with the secondary form.

I'd go back and revisit the design, to make sure you've linked the tables correctly.


Remember, you're unique - just like everyone else
You're invited to visit another free Access forum:
or my site,
 
So, using an ID number from one form, you want to open a second form and create a new record in the second form's underlying table?

How are you passing the ID number currently to the second form? Are you using something like:
Code:
"DoCmd.OpenForm ... , OpenArgs:=123"?

If so, try this in the second form:
Code:
Private Sub Form_Open(Cancel As Integer)
    If Not IsNull(Me.OpenArgs) Then
        DoCmd.GoToRecord , , acNewRec
        Me.IDFieldName = Me.OpenArgs
        DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
    End If
End Sub


 
I am not passing the ID number that way. I simply (maybe too simply) put a text box on the secondary form with
=[Forms]![frmAllData]![ID]
as the source. So the ID number is showing up on the form - just like I need it to. Now I need to be able to store it - not just look at it.
 
Instead of setting the control source of the text box of the secondary form, set it to the field where you want to save the foriegn key.

Then in the event that opens that form add a line that passes the ID directly to that text box.

i.e. in the main form even that opens the secondary form:

docmd.OpenForm "frmAddress",,,,acFormAdd
Forms!frmAddress!txtMainID=[ID]



_________
Rott Paws
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top