Results 1 to 3 of 3
  1. #1
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Add new record (97-->)

    I am having one of my days again!!! <img src=/S/cranky.gif border=0 alt=cranky width=18 height=25>

    I have this code in a form:

    .....

    Set db = CurrentDb
    Set rs = db.OpenRecordset("tblCleanBlockData")
    strSQL = ("SELECT * FROM tblCleanBlockData where BlockID=" & Me.BlockID)

    Forms!frmRAMain!sfrmVChair!sfrmSMSDetails!BlockNam e = Me.StructureName.Value
    Forms!frmRAMain!sfrmVChair!sfrmSMSDetails!BlockNo = Me.StructureRef.Value


    ......

    sfrmSMSDetails is collecting Block names and Block numbers from a look up form and when I select the block from the look up form want a new record to be added to sfrmSMSDetails I can't remember how to do add new as at the moment it is just changing the current record on the subform. <img src=/S/hairout.gif border=0 alt=hairout width=31 height=23>
    Jerry

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Add new record (97-->)

    You should set focus to the subform first, then move to a new record:

    Forms!frmRAMain!sfrmVChair.SetFocus
    Forms!frmRAMain!sfrmVChair!sfrmSMSDetails.Setfocus
    RunCommand acCmdRecordsGoToNew

    BTW, what do the first three lines have to do with the last two ones?

  3. #3
    Platinum Lounger
    Join Date
    Feb 2002
    Location
    A Magic Forest in Deepest, Darkest Kent
    Posts
    5,681
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Add new record (97-->)

    Thanks Hans

    One of these days I will feel confident with the SQL part of the VBA. <img src=/S/whisper.gif border=0 alt=whisper width=29 height=17> You have asked me this before but I never answered. I reused this code from another database I created when I used a similar method... I suppose it is a case of "well if it works I won't change it" and probably underlines my need to brush up on this.
    Jerry

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •