I'm having no luck getting these forms to do what I'm looking for, so I'm pasting my exact code.  The subform (Study2_B_SSRPH) is opened by a button on the main form (Study2_Main).  The subform currently opens to the same record that is open on the main form, which is good.  I would also like it to create a record with the same key field as the active record on the main form, if one does not already exist.  The key field is ID_Number. 

Do I need to add code to the subform to get what I'm looking for?  At this point I only have code on the main form button.  Thanks for your help!  The code is below.

Code for the button on the Study2_Main form:

Private Sub B_Click()
On Error GoTo Err_B_Click

    Dim stDocName As String
    Dim stLinkCriteria As String

    stDocName = "Study2_B_SSRPH"
   
    stLinkCriteria = "[ID Number]=" & Me![ID Number]
    DoCmd.OpenForm stDocName, , , stLinkCriteria

Exit_B_Click:
    Exit Sub

Err_B_Click:
    MsgBox Err.Description
    Resume Exit_B_Click
   
End Sub

 


--- In AccessDevelopers@yahoogroups.com, "Carl Beck" <[EMAIL PROTECTED]> wrote:
>
> The standard template for Order Entry has this function, If you don't find
> an answer here try the db wizard and view the code.
>
>
>
>
>
> _____
>
> From: AccessDevelopers@yahoogroups.com
> [mailto:[EMAIL PROTECTED] On Behalf Of Geoff B
> Sent: Wednesday, January 18, 2006 8:50 PM
> To: AccessDevelopers@yahoogroups.com
> Subject: [AccessDevelopers] Re: Open subform to a related record on the main
> form
>
>
>
> This works as long as there is an existing record in the table with
> the ID Number I'm entering on the Main form. Is there a way to
> display a new record in the subform, which is populated with the ID
> Number I entered on the Main form, if the ID Number does not already
> exist in the table that is linked to the subform?
>
> Thanks for your help!
> Geoff
>
>
> --- In AccessDevelopers@yahoogroups.com, "Duane Hennessy"
> [EMAIL PROTECTED] wrote:
> >
> > Geoff,
> > If the form you are opening is a bound form then on the button
> that opens the form (or whatever event opens it) set a filter upon
> opening the form like so...
> >
> > Docmd.OpenForm, "Form Name", acNormal,, "[record number]=" & me!
> [record number]
> >
> > There is a 'Where' property in the openForm command which is where
> I put the detail above.
> >
> > Hope that helps
> >
> > Duane Hennessy
> > Bandicoot Software
> > Tropical Queensland, Australia
> > (ABN: 33 682 969 957)
> >
> > Your own personal library of code snippets.
> > http://www.bandicootsoftware.com.au
> >
> > --- In AccessDevelopers@yahoogroups.com, "Geoff B"
> [EMAIL PROTECTED] wrote:
> > >
> > > This is an Access question-
> > >
> > > I have a form that I call "Main" with buttons to open a bunch of
> other
> > > forms depending on what type of data I need to enter. The
> problem is,
> > > when I click the button to open another form, the key
> field "record
> > > number" is not populated. I would like the subform (if I should
> call
> > > it that) to be populated automatically when it opens with the
> record
> > > number that I entered on the "Main" form. Currently, I have to
> select
> > > that number from a drop-down menu, but that leaves room for error.
> > >
> > > Can anyone tell me what syntax I need to add to the buttons to
> achieve
> > > this? Thanks!
> > >
> >
>
>
>
>
>
>
>
> Please zip all files prior to uploading to Files section.
>
>
>
>
> SPONSORED LINKS
>
>
> Microsoft
> <http://groups.yahoo.com/gads?t=ms&k=Microsoft+access+developer&w1=Microsoft
> +access+developer&w2=Microsoft+access+help&w3=Microsoft+access+database&w4=M
> icrosoft+access+training&w5=Microsoft+access+training+course&w6=Microsoft+ac
> cess+programming&c=6&s=193&.sig=d-CjBIrYOH9NCKHYFeGZJA> access developer
>
> Microsoft
> <http://groups.yahoo.com/gads?t=ms&k=Microsoft+access+help&w1=Microsoft+acce
> ss+developer&w2=Microsoft+access+help&w3=Microsoft+access+database&w4=Micros
> oft+access+training&w5=Microsoft+access+training+course&w6=Microsoft+access+
> programming&c=6&s=193&.sig=crx-d4AAhdklv_VozGVAUw> access help
>
> Microsoft
> <http://groups.yahoo.com/gads?t=ms&k=Microsoft+access+database&w1=Microsoft+
> access+developer&w2=Microsoft+access+help&w3=Microsoft+access+database&w4=Mi
> crosoft+access+training&w5=Microsoft+access+training+course&w6=Microsoft+acc
> ess+programming&c=6&s=193&.sig=qg2hDuQNweByMCX0NU7cEA> access database
>
>
> Microsoft
> <http://groups.yahoo.com/gads?t=ms&k=Microsoft+access+training&w1=Microsoft+
> access+developer&w2=Microsoft+access+help&w3=Microsoft+access+database&w4=Mi
> crosoft+access+training&w5=Microsoft+access+training+course&w6=Microsoft+acc
> ess+programming&c=6&s=193&.sig=bLZHqTqWUQny609X1OkmNA> access training
>
> Microsoft
> <http://groups.yahoo.com/gads?t=ms&k=Microsoft+access+training+course&w1=Mic
> rosoft+access+developer&w2=Microsoft+access+help&w3=Microsoft+access+databas
> e&w4=Microsoft+access+training&w5=Microsoft+access+training+course&w6=Micros
> oft+access+programming&c=6&s=193&.sig=d8GQXfQW3RZ64rOfzIMo8A> access
> training course
>
> Microsoft
> <http://groups.yahoo.com/gads?t=ms&k=Microsoft+access+programming&w1=Microso
> ft+access+developer&w2=Microsoft+access+help&w3=Microsoft+access+database&w4
> =Microsoft+access+training&w5=Microsoft+access+training+course&w6=Microsoft+
> access+programming&c=6&s=193&.sig=iXDlL79-kkgjv6fLyFu3Sg> access
> programming
>
>
>
> _____
>
> YAHOO! GROUPS LINKS
>
>
>
> * Visit your group "AccessDevelopers
> <http://groups.yahoo.com/group/AccessDevelopers> " on the web.
>
> * To unsubscribe from this group, send an email to:
> [EMAIL PROTECTED]
> <mailto:[EMAIL PROTECTED]>
>
> * Your use of Yahoo! Groups is subject to the Yahoo!
> <http://docs.yahoo.com/info/terms/> Terms of Service.
>
>
>
> _____
>




Please zip all files prior to uploading to Files section.




YAHOO! GROUPS LINKS




Reply via email to