Rabu, 06 Juli 2011

[MS_AccessPros] Re: Code Not Working

 

Abdul

Maybe there is an error in your SQL statement. Put a break point on this line:
Set db = CurrentDb()

Run the code. When it stops open the Immediate window and type this"
?strSql

Press Enter. This will print out the string in the Immediate window so you can see exactly what JET sees. Copy the string and try running it in a new query in SQL view.

Regards,
Bill Mosca, Founder - MS_Access_Professionals
http://www.thatlldoit.com
Microsoft Office Access MVP
https://mvp.support.microsoft.com/profile/Bill.Mosca

--- In MS_Access_Professionals@yahoogroups.com, Abdul Shakeel <abdul.shakeel@...> wrote:
>
> Hi All,
>  
> I am using following code to update subform from another table but having Run Time Error "3201" can any one tell me what I am doing wrong.
>  
> Private Sub CustomerCode_AfterUpdate()
>     Dim db As DAO.Database
>     Dim strSql As String
>     Dim rs As DAO.Recordset
>     Dim rs1 As DAO.Recordset
>     Dim lngReceiptID As Long
>    
>     strSql = "SELECT tblCustomerInvoices.ID, tblCustomerInvoices.CustomerCode, tblCustomerInvoices.InvoiceDate, tblCustomerInvoices.InvoiceNo, tblCustomerInvoices.InvoiceAmount, tblCustomerInvoices.Allocate, tblCustomerInvoices.Status " & vbCrLf & _
>             "FROM tblCustomerInvoices " & vbCrLf & _
>             "WHERE (((tblCustomerInvoices.CustomerCode)=""" & [Forms]![Form5]![CustomerCode] & """));"
>            
>     Set db = CurrentDb()
>     Set rs = db.OpenRecordset(strSql, dbOpenDynaset)
>     Set rs1 = db.OpenRecordset("tblReceiptLines", dbOpenDynaset)
>     lngReceiptID = Me.ReceiptID
>    
>     Do While Not rs.EOF
>     rs1.AddNew
>     rs1!ReceiptID = lngReceiptID
>     rs1!InvoiceNo = rs!InvoiceNo
>     rs1!InvoiceDate = rs!InvoiceDate
>     rs1!InvoiceAmount = rs!InvoiceAmount
>     rs1.Update
>     rs.MoveNext
>     Loop
>    
>     Set rs = Nothing
>    
> End Sub
>
>  
> Thanks & Regards,
> --
> Abdul Shakeel
>
>
> [Non-text portions of this message have been removed]
>

__._,_.___
.

__,_._,___

Tidak ada komentar:

Posting Komentar