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. ScottGem 68,840 Reputation points Volunteer Moderator
    2022-08-10T22:43:55+00:00

    Glad I was able to help you out and pique your interest in Access.

    Its a good idea to close a question and start a new one if you have other issues. That's what this forum is for.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2022-08-10T13:30:13+00:00

    Hey man, with an eye on the amount of time and effort you've already put into helping me out here, I'm going to go ahead and mark this as completed. I was talking about it to my friend, and I'm probably always going to have more questions. It's not really your job as a volunteer to teach me a crash course on Access. I reallllllllllly appreciate all of your help and I think that this is going to become a hobby of mine - it's really interesting. I have a functional db now, so I can't really justify spending the work time that I want to spend making it a "proper" db. That being said it's super interesting, and I'll probably just do it the right way at lunch or at home. You guys have been soooo much help - thanks so much!

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2022-08-08T18:37:42+00:00

    I kept poking the PI combobox until it made it so that when you pick a PI, it goes to that record and populates the rest of the form. The only issue I have now is that it doesn't seem to want to let me apply the filter, so PIs appear in the order they were entered into the db instead of alphabetical order. I don't want to spend a ton of time figuring out why b/c ultimately I want the relational version of the db working and it's early in the physical year so it's not really an issue yet. I'll play w/ the wizard on the new form in a minute though :)

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2022-08-08T17:54:41+00:00

    So, I'm not seeing a subform in your image. Also, why do you think "have it set up for the user to navigate through the database using the PI field."

    Two different forms. The one I'm showing is the functional one b/c boss needed something that worked; the one using relational tables is still in progress b/c I'm still trying to figure out how to implement it.

    The GrantID should be the main point of navigation. Your main Grant form is keyed on GrantID. If you need to show the PI info, that should be shown in a subform linked on GrantID. You should be able to navigate through the various PI records in the subform and edit each.

    I understand every individual word you just said, but when I try and put them together I go crosseyed and curl up in the fetal position and want a blankie lol. I think algorithmically you're saying:

    1. Use GrantID instead of PI, then juts sort by PI since GrantID isn't a field that has any meaning to the user.
    2. Go up and down by GrantID, which would be hidden, so I'd basically have a combobox that had GrantID|PI w/ GrantID having column width of 0.

    ---> tried it and it worked :) :) :) man you rock

    Was this answer helpful?

    0 comments No comments