Results 1 to 10 of 10
  1. #1
    4 Star Lounger
    Join Date
    May 2002
    Location
    Roanoke, Virginia, USA
    Posts
    493
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Forms (2000 SR-1)

    I want to open a form that loads all the records from tblCustomers. If I use OnOpen =
    DisplayAll, all the records are available; however, the first record is displayed. What I want is for
    all records to be available but for a blank new record screen to be displayed.

  2. #2
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Forms (2000 SR-1)

    Are you using code or macros?

    If you're using a Macro, add another line to the OnOpen macro - GoToRecord (NewRecord)

    If you're using code, add this line to the OnOpen event:
    DoCmd.GoToRecord acDataForm, "<FormName>", acNewRec

    (Be sure to change <FormName> to the name of your form)

    HTH

  3. #3
    3 Star Lounger
    Join Date
    Dec 2000
    Location
    USA
    Posts
    379
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Forms (2000 SR-1)

    If you place this code on the OnOpen event:

    <pre>Private Sub Form_Open(Cancel As Integer)

    On Error GoTo Err_cmdAdd_Click


    DoCmd.GoToRecord , , acNewRec

    Exit_cmdAdd_Click:
    Exit Sub

    Err_cmdAdd_Click:
    MsgBox Err.Description
    Resume Exit_cmdAdd_Click

    End Sub</pre>


    when the form opens, it will open to a blank record ready for data entry. Since Access appends records, it will be positioned at the last record, but you can navigate through all the others.

    I'm not all all clear why you want to do it this way. You may encounter difficulties if the user doesn't wish to enter a record at that point. I typically place an Add button on the form for users to add a record, but there it is none the less.

  4. #4
    4 Star Lounger
    Join Date
    May 2002
    Location
    Roanoke, Virginia, USA
    Posts
    493
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Forms (2000 SR-1)

    Thanks. Works great. I will do some testing if the user doesn't want to enter record at this point. I do have an Add Button on the form as well as a Find Last button. MyI only thought was not to display the first record where the operator might inadvertantly change some information. I probable shuld an a confirmation warning before update.

    Thanks again.

    Tom

  5. #5
    4 Star Lounger
    Join Date
    May 2002
    Location
    Roanoke, Virginia, USA
    Posts
    493
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Forms (2000 SR-1)

    I tried the following by adding to frmCheckIn ONOpen event

    DoCmd.GoToRecord acDataForm, "&It;frmCheckIn", acNewRec

    I got the following error message

  6. #6
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Forms (2000 SR-1)

    This may not matter now, but something you'll want to fix for later - you used "<" in the Form Name argument. That is not a valid operator in VB/VBA.

    You must have copied and pasted from the web page and accidentally included the Less than (<) symbol from the left side of my example. That would explain the reason it couldn't find the form name.

    Also, make sure there are no spaces after DoCmd. - that would explain the "Can't find macro.." error.

    Be very careful when writing code - every character counts!

    HTH

  7. #7
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    NYC,USA,Earth
    Posts
    273
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Forms (2000 SR-1)

    If your going to use the objecttype and objectname (you don't need to) try using the name property of the form.

    DoCmd.GoToRecord acDataForm, Me.Name, acNewRec

  8. #8
    4 Star Lounger
    Join Date
    May 2002
    Location
    Roanoke, Virginia, USA
    Posts
    493
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Forms (2000 SR-1)

    Thanks For your reply.
    I have tried both these and still get the same error message:
    The expression you entered contains invalid syntax
    You may have entered an operand with an operator

    DoCmd.GoToRecord acDataForm, Me.Name, acNewRec

    There is no space on either side of the period between DoCmd and GoToRecord
    There is a space after GoToRecord
    There is a space after the comma following acDataForm
    There is a space after the comma following Me Name

    DoCmd.GoToRecord acDataForm,

  9. #9
    4 Star Lounger
    Join Date
    May 2002
    Location
    Roanoke, Virginia, USA
    Posts
    493
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Forms (2000 SR-1)

    Thanks for your reply

    I was not aware that &It was a substitute of the left bracket. Thanks.

    I have tried both these and still get the same error message:
    The expression you entered contains invalid syntax
    You may have entered an operand with an operator

    DoCmd.GoToRecord acDataForm, Me.Name, acNewRec

    There is no space on either side of the period between DoCmd and GoToRecord
    There is a space after GoToRecord
    There is a space after the comma following acDataForm
    There is a space after the comma following Me Name

    DoCmd.GoToRecord acDataForm,

  10. #10
    3 Star Lounger
    Join Date
    Feb 2001
    Location
    NYC,USA,Earth
    Posts
    273
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Forms (2000 SR-1)

    Is there anything else going on in the open event? Your code looks good, I tested it in one of the northwind forms and it worked. The only other thing I can think of is to move it to the onload event, but you shouldn't have to. Might be worth it just as a troubleshooting step.

Posting Permissions

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