GoToRecord stopped working during Form_Load()

Anonymous
2022-07-25T14:54:36+00:00

TL;DR - I want to inputbox("What recordID") then doCmd to go to that ID. It was working fine, then it stopped and I can't make it work again. error is 2046 DoCmd isn't available right now. Now idea why.

Private Sub Form_Load()

myRecord = InputBox("What's the recordID?")

DoCmd.GoToRecord , , acGoTo, myRecord

End Sub

This worked for the first hour or so I was working. Eventually after I added a command button for SOME REASON it stopped working. I deleted the button. Still won't work. Nothing I do will make it work and I've been playing with such a small stupid thing for like 30 minutes. Needless to say, I am not a programmer by trade or passion - this is just something that I know needs to be done at work and no one else knows how to do it. Searching the internet, the only thing I can think of is that the records aren't editable except I've checked both w/ the design form gui and programmatically that they're editable and they are. I'm completely at a loss. Sorry for the dumb question - I'm sure it's something simple, but not being able to figure it out is stopping me from working.

Edit: Even if I put in (for example) a command button using the built in functionality to go to the first/last/next/etc. record, the button doesn't do anything. All of this worked before; I have no idea what changed it. I did not touch the form_load() code at all; I wasn't even working on that when it broke.

Microsoft 365 and Office | Access | Other | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments
Answer accepted by question author
ScottGem 68,840 Reputation points Volunteer Moderator
2022-08-08T18:32:10+00:00

There are a couple of different ways to do this. You can navigate to a specific record by using the navigation buttons at the bottom of the form. But that can be cumberson.

Most developers wil use some sort of search facility to postion the form at the record they want to see. The combobox wizard can create such a search combo (the third option). You can further customize it after the wizard does it's job by modifying the Rowsource. The key is the code the wizard generates to position the form at the selected record. Another method is to create a search form to find the record then open another form filtered for the record you want.

Was this answer helpful?

1 person found this answer helpful.
0 comments No comments

57 additional answers

Sort by: Most helpful
  1. Anonymous
    2022-07-25T15:42:40+00:00

    Thanks, I did this successfully but it didn't seem to change anything.

    The form populates like this if I bypass or comment out the part that directs it to a specific record. Before this error magically appeared (I did NOT change the code in form_load ), this would always be either record 1 or the record I pointed at. Now it's uneditable; it's like somehow it doesn't know it's attached to the table anymore. I know that it knows what table it's attached to though b/c if I try to load it with the table open, it won't - it throws an exception "blah blah Table1 is open so you can't open this right now" basically.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2022-07-25T15:40:26+00:00

    I'm having the same issue basically, but I did notice something odd. Look at this:

    I have no idea why that says "Expr1000" instead of SIRO ID. I don't remember it saying that before I started having issues, but maybe I just didn't notice it. It doesn't seem like it should be relevant to the problem though.

    The field is SIROID. Maybe it says that b/c it's an autonumber. My point was having it assign a unique numerical ID that I could always pull from. I tried to set it up to search by professor name bt it won't work because somehow it's not associating my form with the table properly anymore. If I bypass the Form_Load() error, it shows this:

    Prior to things going wrong, it would always show me a specific record (even if it was the first one) with all associated fields properly populated.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2022-07-25T15:34:07+00:00

    The issue is that I need a unique identifier to be able to find the record in question. I anticipate getting about a hundred new records per year, and unfortunately a lot of information could be the same.

    Ex: Mr. Blah might have 20 records. I could potentially sort by record creation date, but ultimately when looking this up the user (which will be one of 3 people, including me) needs to know that recordID b/c I don't have another way to track it.

    THAT BEING SAID for now I just need the thing to work so that I can continue building and get SOMETHING functional before my boss gets back from vacation next week lol, so I'm going to try this. Thanks so much for your timely response. What's frustrating me is that it was working fine the first hour I was working on this, then I tried to add a combo box to do something (I don't even remember what anymore) and magically it stopped working. When I clicked undo, it still didn't work. It hasn't worked since. No matter what form I go to now, the forms no longer seem to be properly associated with records. They no longer show the unique identifier, and all fields are blank/null/whatever. They're no longer editable. It's like I unaffiliated all forms with the table they're drawing from. (No, I didn't rename the table by accident; I've checked like 10x). This is so frustrating =/

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2022-07-25T15:30:13+00:00

    This is what happens

    Was this answer helpful?

    0 comments No comments