Append Query Not Working

MCCDOM

Registered User.
Local time
Today, 05:26
Joined
Oct 30, 2014
Messages
84
Hi There,

I am trying to create a very simple append query that takes the primary ID's from each table (tblName, tblOffices and tblMailbox) and adds them to the tblBreakdown dependent on the selected data in the three comboboxes (cboName, cboOffice and cboMailbox) on frmMailboxAssignment.
What should happen is I select a name an office and a mailbox type via the comboboxes and then press on btnAssign. This should run my qryAppendBreakdown which will take the associated ID's of the name, office and mailbox type and stick it in the tblBreakdown (see attachment for table).
Now what is happening is nothing. It doesn't select any ID's and doesn't input anything into the tblBreakdown.

My code is as follows:

Code:
Private Sub btnAssign_Click()
On Error GoTo btnAssign_Click_Err

    DoCmd.OpenQuery "qryAppendBreakdown", acViewNormal, acAdd
    

btnAssign_Click_Exit:
    Exit Sub
    
btnAssign_Click_Err:
    MsgBox Error$
    Resume btnAssign_Click_Exit
    
End Sub

And my query is as pictured (see attachment).

I would appreciate any help you can give me please.

Many thanks,

Dom
 

Attachments

  • qryAppendBreakdown.JPG
    qryAppendBreakdown.JPG
    28.5 KB · Views: 141
  • tblBreakdown.JPG
    tblBreakdown.JPG
    19.8 KB · Views: 122
you dont need the parameters, just
DoCmd.OpenQuery "qryAppendBreakdown"
 
Hi Ranman,

Thanks for your reply.

I have deleted the "acViewNormal, acAdd" part of the code but it still doesn't pick up any of the ID numbers.

I just get a message you are about to append 0 row(s).
 
Post your database with some sample data + name of the form where you've the code.
 
Hi JHB,

Thank you for your reply.

Please find attached my database.

Many Thanks,

Dom
 

Attachments

You where making it too complicated.
In your query you were linking all the tables and forcing criteria onto the results, you don't need to do that, as it will stop the append from happening.
See the attached.
 

Attachments

The query was total wrong:
Append data can be done in many ways, but to follow what you have chosen change the query to the below:
INSERT INTO tblBreakdown ( StaffID, OfficeID, MailboxID )
SELECT [Forms]![frmMailboxAssignment]![cboName] AS Staffid1, [Forms]![frmMailboxAssignment]![cboOffice] AS OfficeID1, [Forms]![frmMailboxAssignment]![cboMailbox] AS MailboxID1;
 
Hi Minty,

That is perfect, thank you. There was me thinking its not complicated enough being the issue.

Kind regards,

Dom
 
Thanks for your help JHB.

Kind regards,

Dom
 

Users who are viewing this thread

Back
Top Bottom