Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old September 25th, 2004, 08:13 AM
Friend of Wrox
Join Date: Aug 2004
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts
Default Having problems retrieving an array to a table!

Have array1 and have array2 printed on the immediate window.Array1 comes from tb1 and array2 comes from array1 and fieldE which is not
on tb1.Tb1 and tb2 have no fields in common to make a one-to-many relationship.I am having problems to insert array2 in tb2.Here comes the code:
      Sub InsertARecord1(str0 As Variant, str1 As Variant, _
    str2 As Variant, str3 As Variant, str4 As Variant)
Dim cmd1 As ADODB.Command

Set cmd1 = New Command

With cmd1
    .ActiveConnection = CurrentProject.Connection
    '.CommandText = "INSERT INTO Tb2(ID, " & _
        " Nome, Código, Evento, Dia1,Dia2,Dia3) VALUES (" & str0 & "," & str1 & "," & _
        str2 & "," & str3 & "," & str4 & ")"

    .CommandText = "INSERT INTO Tb2 " & _
            "VALUES (" & str0 & "," & str1 & "," & _
       str2 & "," & str3 & "," & str4 & ")"
    .CommandType = adCmdText
End With

End Sub

I have filled strn with array2 and have tried naming the fields and
not naming the fields on the INSERT INTO command.Have not managed to fill Tb2 with strn VALUES.
Have error messages "missing parameters on query Tb2".
Any idea of what i am doing wrong or if this task is not possible are welcome.
Regards P.

Old September 27th, 2004, 05:20 AM
Friend of Wrox
Join Date: Jul 2004
Posts: 345
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via MSN to gokul_blr Send a message via Yahoo to gokul_blr

Just be a little careful when you aren't too strict about the parameters that you expect. For example, although we have specified that some parameters are optional in this script, you should still check for them. If they aren't supplied, you should assign a default value rather than error out the script.

1. Check the no. of coloumns in the table as well as the no. of value paramenter specified in the query.
2. Check any mismatch of column Type in the sequence specified & to the table.
3. If you would like to skip any of the coloumn value the proper value should be passed as "NULL", (note : if the definition says NOT NULL value should be passed).

Gokulan Ethiraj
Old September 27th, 2004, 07:23 AM
Friend of Wrox
Join Date: Aug 2004
Posts: 159
Thanks: 0
Thanked 0 Times in 0 Posts

Thank u Gokulan for ur attention!
Have cheked ur itens 1,2,3 and now have error message "missing operator on query Tb2". Despite that i have created an intermediate tb3 linking Tb1 and Tb2 if that is something that may make this task easier.
Regards P.

Similar Threads
Thread Thread Starter Forum Replies Last Post
Retrieving data from a table given a PK value galaxy3 VB Databases Basics 1 June 22nd, 2006 12:12 PM
problems in retrieving attribute value.... vcplearner All Other Wrox Books 0 October 17th, 2005 05:22 PM
retrieving multiple rows from table blackbeauty SQL Language 1 August 8th, 2005 03:55 AM
Retrieving items from a table - Immediate Help badprogrammer Access VBA 2 May 4th, 2005 02:39 PM
VBA in Outlook: Problems retrieving dates Sach VB How-To 1 April 13th, 2004 07:59 AM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.