• Is CurrentRecord the way to go? (2000)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Is CurrentRecord the way to go? (2000)

    Author
    Topic
    #374955

    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

    Viewing 1 reply thread
    Author
    Replies
    • #608300

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

    • #608362

      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.

    Viewing 1 reply thread
    Reply To: Is CurrentRecord the way to go? (2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: