Results 1 to 3 of 3
  1. #1
    Star Lounger
    Join Date
    Feb 2002
    Posts
    74
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Is CurrentRecord the way to go? (2000)

    I am working on a form that is populated with records based on different filters. I want to be able to update a Yes/No field on one of the filtered records with code behind a button on the form (the field to update is not on the form). How can I reference the form that is currently visible?

    I figured that I could use the CurrentRecord property, which does tell me what row in the recordset the record is in - but I'm not sure how to apply that information to my situation. Here's what I have so far:

    Private Sub cmdShowAgain_Click()
    Dim recordnum As Integer
    Dim strSql As String
    Dim frm As Form
    Set frm = Forms![frmQA]
    recordnum = frm.CurrentRecord
    DoCmd.SetWarnings False
    strSql = "UPDATE tblQA SET tblQA.omit = 0 WHERE (????????????)
    DoCmd.RunSQL strSql
    DoCmd.SetWarnings True
    End Sub

    Thanks,

    Randy

  2. #2
    Gold Lounger
    Join Date
    Feb 2001
    Location
    Sint Niklaas, Belgium
    Posts
    2,778
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Is CurrentRecord the way to go? (2000)

    Why don't you put the field on the form and make it invisible.
    You could then use Me.blnomit = 0
    Francois

  3. #3
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Is CurrentRecord the way to go? (2000)

    You don't use CurrentRecord like that. Anytime you refer to a form in code, you're referring the to currently selected record. CurrentRecord returns the ordinal number of that record in the form's recordset, and that isn't what you need because it is affected by filters and sorting. You must use values in your records that help identify those records. That's what primary and foreign keys (indexes) are for.
    Charlotte

Posting Permissions

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