Page 1 of 2 12 LastLast
Results 1 to 15 of 30
  1. #1
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    No current record on form linked to query (2000)

    Hi All,

    I have a form whose control source is query. I am attempting to open the form to find a name that is on a list on a different form. I have used code from this forum that has worked in the past. The only difference is the form that was being opened was linked to a table not a query.

    My problem, when I doubleclick the name on the list used to open the form I get a message that says no current record. First I assumed it was because I had to somehow requery the query the form is linked to. (I'm not sure how to do this but it is where my thoughts went), however if I open the form on its own, it automatically opens to the first record in the query. Thus I am confused as to why the the message stating "no current record". How do I get past this??

    Thanks,
    Leesha

  2. #2
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts

    Re: No current record on form linked to query (2000)

    How do you open the form, is it with DoCmd.OpenForm and a criteria?

  3. #3
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: No current record on form linked to query (2000)

    Hi Pat

    frmAccountName opens frmDemographics by double clicking a name in lstAllAcccountNames. The code is as folllows:

    Private Sub lstAllAccountNames_AfterUpdate()
    ' Find the record that matches the control.
    Dim rs As Object

    Set rs = Me.Recordset.Clone
    rs.FindFirst "[AccountID] = " & Str(Me![lstAllAccountNames])
    Me.Bookmark = rs.Bookmark

    End Sub

    Private Sub lstAllAccountNames_DblClick(Cancel As Integer)
    DoCmd.OpenForm FormName:="frmDemographics", _
    WhereCondition:="AccountID = " & Me.lstAllAccountNames

    DoCmd.Close acForm, "frmAccountName", acSaveYes

    End Sub


    The "on load" code in frmDemographics is:


    [FullName] = [SALUTATION] & " " & [FirstName] & " " & [MiddleInitial] & " " & [LastName/BusinessName] & " " & [SUFFIX]

    Me.AccountType.SetFocus

    __________________________________________________ ________--

    If I open frmDemographics by itself without using the list on frmAccountName, it opens to show the first record in the query. It is only when I open it from the list on frmAccountName that I get an error that says "no current record".

    Thanks,
    Leesha

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: No current record on form linked to query (2000)

    Hi Leesha,

    Try commenting out the line [FullName] = ... in the OnLoad of frmDemographics temporarily (insert ' before the line).
    What happens now if you double click the list box? Does frmDemographics open with the correct record, or does it open on an empty record?

    Note: acSaveYes in DoCmd.Close acForm, "frmAccountName", acSaveYes means that you save the design of the form, not that you save the record (that will be done automatically by Access). Saving the design of a form will fail if more than one person uses the database.

  5. #5
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: No current record on form linked to query (2000)

    Hi Hans,

    I took out the line as you suggested and it opens fine, to the record I want. Of course now that leads to two questions. First, my need to understand the process (vs just copy code given to me) - why did this happen? When I think of the hours I spent trying to find the fix before posting and bothering you guys! Jeese!

    Second question - since that line blows up the load process where would you suggest I put it so that the FullName box populates the way I need it to?

    Finally, thanks for your tip re the form save. I had no idea! As always, I appreciate any and all help/tips you provide.

    Leesha

  6. #6
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: No current record on form linked to query (2000)

    Hans!!! I found a fix. I tried putting the code back in after the "me.AccountType.setfocus" code and it worked. I figured that if the code re the FullName loading first was blowing up because the "current record" hadn't been found yet, possibly inserting it after the record had been found and the focus set to a source on the form would correct the problem!! Ask me if I'm tickled tee hee.

    Thanks Again,
    Leesha

  7. #7
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: No current record on form linked to query (2000)

    I'm glad you found it yourself. One of the possibilities was indeed that the OnLoad event occurs too early to manipulate data.

  8. #8
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: No current record on form linked to query (2000)

    I spoke too soon. I'm not sure why as I haven't made any changes to the forms as listed previously and now I'm getting the "no Current Record" error again, withe following code highlighted Me.Bookmark = rs.Bookmark. I took everything out of the load event on frmDemographics, but still get the message. I've tried having frmDemographics already open and populated with an account in it to see if that was the issue, but I still get the no current record error. If I run the query that frmDemographics is bound to it shows the accounts. If I open frmDemographics on its own it shows the first account in the query. It's only when I try to open it from frmAccountName. HELP?!

    Totally confused,
    Leesha

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: No current record on form linked to query (2000)

    Is the highlighted instruction "Me.Bookmark = rs.Bookmark" the one from the lstAllAccountNames_AfterUpdate procedure in frmAccountName that you posted in an earlier reply, or is it in code belonging to frmDemographics?
    If it is in frmAccountName, the problem is in that form. Apparently you clicked on a value in the list box that doesn't correspond to an existing record.
    If it is in frmDemographics, post the relevant code from that form, so that we can see the instruction in its context.

  10. #10
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: No current record on form linked to query (2000)

    Now I'm really stumped. I had closed down the project and went on to something else (eye strain) and when I opened it up to look at the areas you suggested. It ran fine. Makes no sense. I guess I should've resorted to the first troubleshooting trick I tell people at my office to resort to when the computer/programs are nuts - shut down and reboot.

    Thanks!

    Alicia

  11. #11
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: No current record on form linked to query (2000)

    I'm so frustrated. The two forms I mentioned above have been working fine. I've been fine tuning them to lock them down the user needs and now when I go to open a new record either I get an error message that states that record isn't available, (when the command is on frmDemographics itself) or if I open frmDemographics from frmAccountName with the following code .... DoCmd.OpenForm "frmDemographics", acNormal, , , acFormAdd
    frm Demographics opens to the first record in the query. It makes no sense to me at all. I've read and re-read the code and can't find anything that would override the code to open a new record I've attached the code to both sheets in case someone can see what its wrong.

    The way it is supposed to work, the user clicks the command to open a new record, from frmAccountName. frmAccountDemographics should open to a new form.

    Thanks,
    Alicia
    Attached Files Attached Files

  12. #12
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: No current record on form linked to query (2000)

    You're getting the "No current record error" in frmAccountName, not in frmDemographics. When you double click a list box, the On Click event occurs first, then the On DblClick event. After all, you click once first, then immediately afterwards a second time. The OnClick event tries to move the form to the record whose AccountID is equal to the one selected in the list box. I assume that something goes wrong there - can the list box contain AccountID's that are nor displayed in frmAccountName?

    About the other problem: if the record source of frmDemographics doesn't allow adding new records, or if frmDemographics has its RecordsetType set to Snapshot, the form can't be opened on a new record, so the first existing record will be displayed.

    What is frmAccountDemographics? I see no mention of it in your code.

  13. #13
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: No current record on form linked to query (2000)

    Hi Hans,

    Thanks so much for your quick response. I was hoping you'd be around.
    First, frmAccountDemographics was a typo on my part. It should've read frmDemographics.

    To clarify, when I double click the list box on frmAccountName it opens to the correct record in frmDemographics. There are no problems there. The problem comes when I click the control button on frmAccountName called cmdAddNewName. frmDemographics opens, but to the first record in the query that frmDemographics is bound to, not to a new record. It was working fine. I'm not sure what happened.

    The RecordsetType on frmDemographics is set to dynaset not snapshot.

    Alicia

  14. #14
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: No current record on form linked to query (2000)

    If you open frmDemographics directly, can you add a new record?

  15. #15
    Silver Lounger
    Join Date
    Jan 2002
    Posts
    1,615
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: No current record on form linked to query (2000)

    Nope. I'm "trying" to think like you and figured that would be a suggestion so I put a command on the frmDemographics to add a new record and get the same error message re not being able to go to that record.

    Leesha

Page 1 of 2 12 LastLast

Posting Permissions

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