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-08-01T16:35:52+00:00

    Annd I just realized my methodology would doesn't support multiple PIs, which is probably why you (or someone?) had me make tblPIAssigned to begin w/. I need to think this through. I swear I spend more time staring at my pc thinking than I do actually typing. My boss probably thinks I'm daydreaming.

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2022-08-01T16:20:24+00:00

    Based on this, I changed some stuff around. Because all awards must be affiliated w/ a specific grant and we already have a field explicitly identifying grants, I'm going to make GrantID the primary key in tblAward.

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2022-08-01T16:17:11+00:00

    The term "research" is misleading; either a grant is for Research or it's not (ex: a grant for scholarships ) thus it's CSA. I changed the field to RvCSA and put validation in to force it to be one and to default to Research.

    Here's my current mess. I made some changes that may or may not make sense (based on my track record, they probably don't):

    Here are the changes I'm going to make after this email, by number in the pic:

    1. Things that are X'd out existed originally, but I plan on deleting them today.

    Here's what I think I actually want to happen:

    1. User wants to make a new grant. User clicks the new grant button. This brings up a New Grant form.
    2. A new record is created and automatically assigned a new GrantID
    3. The user enters pertinent information about everything but the researcher name (PI). This will be selected from a list.
      1. If the researcher isn't on the list, a button will pop up a form to enter the six fields in tblPIID that aren't autonumber.
        1. I'm struggling to remember how tblPIAssigned fits into this. Couldn't I just have a single field PIID on GrantID? I can't remember.
      2. Awarded = pending by default; awarded can be Pending, Awarded, or Declined
    4. We now have a new record with a unique GrantID that has everything it needs.
    5. At some point Awarded will be changed to "declined" or "awarded." If declined, the grant is basically done forever.
      1. If awarded, open awarded form, create new record, enter in GrantID
        1. It's possible to have 2 PIs from different colleges. To avoid double-reporting funding on reports, multiple records could be associated with the same GrantID. In this scenario, there is no PK for this field. Idk why that makes me nervous but it does. Maybe it's fine.
      2. User fills in the info. I need to be careful here; it's important that the user puts in the information specific to one PI if there are multiple PIs. My nightmare scenario is that there are two PIs, and the user puts the full amount for both. I need to think through this before going live w/ this.

    Actually looking at that I'm not sure what the point of tblPIAssigned is b/c I don't see where I'd need to use or reference it. It's probably b/c I don't understand how the relationships work. I think it's b/c I think like an amateur programmer instead of an amateur db guy, but I'm working on that. Anyway, feedback welcomed. I'm debating a table for sponsors for all of the reasons I made a table for PIs. The issue I see is that the users would be going into this and adding things A LOT and it may ultimately defeat the point of having it... but for now let's assume I'll make it.

    Also for reference:

    Image

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2022-08-01T13:47:03+00:00

    There will always be a direct cost b/c that's what they're funding. Even if they were trying to fund say our electric bill which would normally be indirect, because that was what they were funding it would change to direct. Indirect is overhead. Some grant granters (there's gotta be a better word for that) will not allow any of the money they give you to go to overhead. Most do. As a result, by default indirect is allowable, but on occasion (usually small foundation grants but hey we'll take every penny) it is not. I'm going to play w/ stuff today though; I've got some down time. It should be interesting.

    Was this answer helpful?

    0 comments No comments