View Single Post
  #8 (permalink)  
Old 05-Nov-2005, 12:48 PM
Secret Squirrel's Avatar Secret Squirrel
Guest
 
Posts: n/a
   
   
Re: Linking two Forms

Ok here is the code from my command button. It is what you said it should be
but when I key information on the second page and then exit out and go back
into it the data is blank. Almost like it's starting a new record.

Private Sub Command209_Click()
On Error GoTo Err_Command209_Click

DoCmd.OpenForm "frmCorrectiveActionRMA", , , "[RMA#] = Forms![2005
Form]![RMA#]"

Exit_Command209_Click:
Exit Sub

Err_Command209_Click:
MsgBox Err.Description
Resume Exit_Command209_Click

End Sub

My primary key on my first form is RMA#. The foreign key on the second form
is also RMA#. I have the foreign key linked to the first form's RMA#. Is that
correct also?

"Joan Wild" wrote:

> OK, let's start from square one.
>
> You wrote
>
> "I have a form where users will do all their data entry. I have
> another form where they can add additional information for that
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/information-technology/6661-linking-two-forms.html
> particular record. The can click on a command button to access
> this other form."
>
> I'm referring to the code you have in the click event for this command
> button. It should be something like
> DoCmd.OpenForm "SecondForm", , , "[SomeID] = Forms![FormOne]![SomeID]"
>
> You would substitute the name of your second form for SecondForm; the name
> of the primary key field for SomeID.
>
> How about you post what is currently in the click event for your command
> button, and also the name of the primary key field in the one form and the
> name of the foreign key in the second form.
>
> --
> Joan Wild
> Microsoft Access MVP
>
> Secret Squirrel wrote:
> > Ok now I'm confused. ;-) I am putting this code in the first forms
> > module? Where exactly is that? The way you explained it below is
> > exactly what I am looking for.
> >
> > "Joan Wild" wrote:
> >
> >> Sorry I was confused with another thread. You are putting that code
> >> in the first form's module. So it will only apply when you open the
> >> second form from the first.
> >>
> >> It's not 'tied' to the first record. If you open your first form
> >> and go to the 6th record (ID=559 for eg.), and you hit the button to
> >> open the second form; the second form will open to show you related
> >> information for ID=559.
> >>
> >> Perhaps I misunderstand your question.
> >>
> >>
> >> --
> >> Joan Wild
> >> Microsoft Access MVP
> >>
> >> Secret Squirrel wrote:
> >>> But will that second form always open to that specific record if
> >>> it's tied into the first record?
> >>>
> >>> "Joan Wild" wrote:
> >>>
> >>>> From form one...
> >>>> DoCmd.OpenForm "SecondForm", , , "[SomeID] =
> >>>> Forms![FormOne]![SomeID]"
> >>>>
> >>>>
> >>>> --
> >>>> Joan Wild
> >>>> Microsoft Access MVP
> >>>>
> >>>> Secret Squirrel wrote:
> >>>>> I have a form where users will do all their data entry. I have
> >>>>> another form where they can add additional information for that
> >>>>> particular record. The can click on a command button to access
> >>>>> this other form. But when they click on this button I want to be
> >>>>> able to carry over the Primary key field (the autonumberID) and
> >>>>> have it populate a field on this other form. This way I can tie
> >>>>> the two tables together. But here's the catch, I want people to
> >>>>> also access this other form via the switchboard as well without
> >>>>> carrying over the Primary Key from that main form. There are two
> >>>>> way to create a record on this form. One is directly and the
> >>>>> other is through the main data entry form. There are two ways a
Reference:: Sikh Philosophy Network http://www.sikhphilosophy.net/showthread.php?t=6661
> >>>>> record can be generated. Am I making sense here?

>
>
>

Reply With Quote
 
Page generated in 0.24971 seconds with 25 queries