简体   繁体   中英

Updating a record on a subform

I have a main form and a subform in Access. The main form is to provide information regarding to a site that my company will be working from. The subform shows all of the individuals that are available on the days in question, so that they can be provisionally booked. These forms are not linked in anyway as, at this stage, there is nothing to link them on.

On my subform (which is a continuous form), I have a button linked to an update query. I think I need some sort of SetFocus or criteria to show that it is only for that one record.

UPDATE Dates SET Dates.[Booked?] = True, Dates.[Site ID] = [Forms]![Frm5 - EditMS]![ID];

When I click the button next to each record for the individual that I want to book, it is updating all the records and not just the one that I want. I have tried to add in criteria as in Individual in table=form field individual (brief overview, obviously) but then it asks me for a parameter so it is not working as I planned. I did try searching the forums but can't seem to find the right words in a search to find the answer! I'm sure it is out there somewhere but I have no idea where to find it!

Thank you in advance for any help :)

It would be a lot smarter to update using the subform where the records are present:

Private Sub BookButton_Click()

    If Me.[Booked?].Value = False Then
        Me.[Booked?].Value = True
        ' Save the record.
        Me.Dirty = False
    End If

End Sub

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM