1
votes

I have two tables in MS Access 2010.

tblStore:

ID ItemID ItemName Out (it's a Yes/No field)
1    A1    ALPHA1  
2    A2    ALPHA2  
3    A3    ALPHA3  
4    A4    ALPHA4  
5    B1    BETA1   
6    B2    BETA2   
7    G1    GIGA1   
8    G2    GIGA2   

tblOut:

ID ItemID ItemName

I created a form from tblStore in tabular layout and added a command button with vba codes:

`Private Sub cmdSendOut_Click()
    DoCmd.RunSQL "INSERT INTO tblOut (ItemID, ItemName)" & _
        "SELECT ItemID, ItemName FROM tblStore WHERE (Out = True);"
    
    DoCmd.RunSQL "DELETE FROM tblStore WHERE (Out = True);"
End Sub`

My problem is: after select 2 records in the form and click the [Send Out] button as shown below, system only show 1 record that need to be appended. enter image description here

Can anybody tell me what went wrong? Thanks!

1
Please do not edit your title or question to indicate that your issue is 'solved'. This is not a support forum, but a question/answer site.Andrew Barber

1 Answers

2
votes

Notice on the screen shot that one record shows a pencil icon. That record is not resolved, not saved. You may find you can save that record before running the queries using VBA:

IF Me.Dirty=True Then Me.Dirty =False

Then I think you will find both records are captured. Screen shot very helpful in this case!