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-07-27T17:20:20+00:00

    The definition of a PK is a value that uniquely identifies a record and does not change. So Autonumbers make good PKs. However, there can be other values in a record that will work as a PK. Thr FK contains the vaslue of the PKfor the related, It has to be the same Data Type as the corresponding PK (Note: Autnumbers are a long intyeger data typ)

    Was this answer helpful?

    0 comments No comments
  2. ScottGem 68,840 Reputation points Volunteer Moderator
    2022-07-27T17:00:30+00:00

    The Recordsource of a form (or report) is either a table or a SQL query. Essentiallu its the recordset that the form displays.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2022-07-27T13:09:36+00:00

    So direct funding vs indirect funding has to do with how the $ is used. It's basically just overhead. Ex: Let's say you get a 500k grant and you're a college professor. You spend 20% of your time that would've been used teaching doing this research instead. The university needs to recoup 20% of your salary off the bat to hire a new teacher. You're also using labs with mortgages, electricity, campus security, taking up space no one else can use, blahblah. There are also administrative overhead costs like me - a grant specialist. Typically (but not always b/c some grants require something different), there's a federally negotiated allowable indirect funding rate ivo 50% that goes on grants. When there isn't (such as with an NGO), we usually use that same rate... but some grants specifically disallow its use. As you can imagine, the powers that be in the university are not fond of that type of grant, but if we're going to move up in the research world like they want us to, we can't really turn away research $.

    With that in mind, would it make sense for me to keep tblGrants the way you suggested it but just add a field GrantIR (grant - indirect funding requested) besides GrantDR (grant direct funding requested) instead of making a tblIndirect? If I did its own table, I'm not sure what I would put into it besides GrantID as an FK (I think?) and the amount of indirect funding requested. I imagine based on your organization that indirect funding awarded would go in tblAwards.

    Another benefit I didn't see until I started doing this is that I think it's going to make the reports a lot easier. I had a vague idea of populating reports with vba if I couldn't use the wizard to do it, but in retrospect that feels like a kind of dated way to do things that would probably create more problems and questions. I think I can just add a field "GrantStatus" to tblGrants then limit it the field to Awarded/Pending/Declined (using validation or something? idk how to sanitize entries; I only know the term b/c of this xkcd joke I saw years ago:)

    Image

    ... and add an FK to the PK of tblAwards, use whatever black magic links the tables (I still have no idea how FKs work - that's my next step I think), then when I need to do reports I can just do a report based on what's in tblAwards and spit it out, then another rpt based on anything that has status "pending" in tblGrants... I think. Idk I'm still trying to wrap my head around this multiple-table thing 😅 . I can't believe how helpful you guys are. 100% if I hadn't posted here, me (or worse, someone that came after me) would be posting here in 5 years about a database w/ 1000+ jacked up field made by an idiot that they needed to fix. I imagine it would be like trying to repair a ship while it was both sinking and still being used lol. You guys are awesome.

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2022-07-27T12:49:29+00:00

    Me: I'm get my foot in the door on this database thing.

    Me 5 minutes later:

    Was this answer helpful?

    0 comments No comments