Search code examples
vbams-access-2007

Adding checkbox to each record in a continuous form in Access 2007


I'm new to VBA and Access. I have to create an inventory loan form which enable users to view and update item loan details of an user. I have created a continuous form which shows the results of the records of a query (My RecordSource of the form is this query).

I currently have a table named "Loan Details" with a Boolean column named "Return status". I've used this column to bound a checkbox to it and placed the checkbox together with the records. I wanted to create such that users can select the checkbox of the specific records, and upon clicking the "update return status" button, there is vba codes that makes use of a query to change the "Return status" to True again.

However, the checkbox does not allow me to select (I think it's because the checkbox only displays the "Return status" value) and I'm not too sure how to go about it.

I know this is a common question, but I tried to search online and cant find anything that solve my problem.

Sorry if I dont sound clear!


Solution

  • That query does not look like it is updateable. To check, try to change a textbox and watch the status bar at the bottom of the MS Access window. It will change from something like "Form View" to "This recordset is not updateable". Simply changing from an implicit to an explicit join would probably help.

    Explicit join

     SELECT * 
     FROM items
     INNER JOIN (
        SELECT [Pdt ID] 
        FROM [Loan Detail] 
        WHERE [Loan Detail].[EmpID] = Forms![Update Form]![IDText]) AS pdtList 
     ON pdtList.[Pdt ID] = items.ID
    

    BTW * is nearly always a bad idea, you should list the fields (columns) you need.