LOUISBUHAGIAR54
Registered User.
- Local time
- Today, 15:00
- Joined
- Mar 14, 2010
- Messages
- 157
Hi everyone on the weekend.
I have the following code:
Private Sub Command5_DblClick(Cancel As Integer)
If IsNull(Me.List0) Then
MsgBox "Choose a client from the list first !"
Exit Sub
Else
DoCmd.OpenReport "RptInvoice", acViewPreview, , , acWindowNormal
Reports!RptInvoice.Filter = " [cltIdcard] = """ & Me.List0.Column(0) & """"
Reports!RptInvoice.FilterOn = True
End If
Set mydb = CurrentDb()
Set rst1 = mydb.OpenRecordset("tblInvoices", dbOpenDynaset)
'filling up a new record from tblInvoices.
rst1.AddNew
rst1!InvDate = Date
rst1!Invoiced = True
rst1!CltID = Me.List0.Column(0)
rst1!UserNameInv = Forms!FrmMain!TxtIdentifier
rst1!Paid = False
rst1!InvAmount = Reports!RptInvoice!TotalSum 'the problem seems to be coming from here although the information passes well when run manually
Me.paste_invoiceno = rst1!InvoiceNo
rst1.Update
rst1.Close
Set rst1 = Nothing
Set mydb = Nothing
'print the report as now you have its invoiceno
DoCmd.OpenReport "RptInvoice", acViewPreview, , , acDialog
Dim StrSQL As String
'mark the tblHospitalisations as invoiced and add invoice no
StrSQL = " UPDATE tblHospitalisations SET tblHospitalisations.InvoiceNo = [Forms]![frmBilling]![paste_invoiceno], tblHospitalisations.invoiced = true" _
& " WHERE (((tblHospitalisations.cltIdcard)=[Reports]![RptInvoice]![cltIdcard]) AND ((tblHospitalisations.invoiced)=false));"
DoCmd.RunSQL StrSQL
'mark the tblservicelog as invoiced and add invoice no
StrSQL = "UPDATE tblservicelog SET tblservicelog.invoiceno =[Forms]![frmBilling]![paste_invoiceno] , tblservicelog.invoiced = true" _
& " WHERE (((tblservicelog.invoiced)=false) AND ((tblservicelog.hospno)=[Reports]![RptInvoice]![cltIdcard]));"
DoCmd.RunSQL StrSQL
'mark the tblinvestigations as invoiced and add invoiceno
StrSQL = "UPDATE tblTest INNER JOIN tblClinPict ON tblTest.IDClinPict = tblClinPict.ID SET tblTest.Invoiceno = [Forms]![frmBilling]![paste_invoiceno], tblTest.Invoiced = true" _
& " WHERE (((tblTest.Invoiced)=false) AND ((tblClinPict.CltID)=[Reports]![RptInvoice]![cltIdcard]));"
DoCmd.RunSQL StrSQL
Me.paste_invoiceno.Value = 0
Me.Requery
End Sub
When I run it with a 'toggle breakpoint' and using F8, it runs well and the InVAmount field in the table tblInvoices fills well according to the amount on the report field (TotalSum).
When the vba code is running alone without a breakpoint the InVAmount on tblInvoices always fills up with '0'.
Is there an explanation for this ?
Many thanks.
LouisB
I have the following code:
Private Sub Command5_DblClick(Cancel As Integer)
If IsNull(Me.List0) Then
MsgBox "Choose a client from the list first !"
Exit Sub
Else
DoCmd.OpenReport "RptInvoice", acViewPreview, , , acWindowNormal
Reports!RptInvoice.Filter = " [cltIdcard] = """ & Me.List0.Column(0) & """"
Reports!RptInvoice.FilterOn = True
End If
Set mydb = CurrentDb()
Set rst1 = mydb.OpenRecordset("tblInvoices", dbOpenDynaset)
'filling up a new record from tblInvoices.
rst1.AddNew
rst1!InvDate = Date
rst1!Invoiced = True
rst1!CltID = Me.List0.Column(0)
rst1!UserNameInv = Forms!FrmMain!TxtIdentifier
rst1!Paid = False
rst1!InvAmount = Reports!RptInvoice!TotalSum 'the problem seems to be coming from here although the information passes well when run manually
Me.paste_invoiceno = rst1!InvoiceNo
rst1.Update
rst1.Close
Set rst1 = Nothing
Set mydb = Nothing
'print the report as now you have its invoiceno
DoCmd.OpenReport "RptInvoice", acViewPreview, , , acDialog
Dim StrSQL As String
'mark the tblHospitalisations as invoiced and add invoice no
StrSQL = " UPDATE tblHospitalisations SET tblHospitalisations.InvoiceNo = [Forms]![frmBilling]![paste_invoiceno], tblHospitalisations.invoiced = true" _
& " WHERE (((tblHospitalisations.cltIdcard)=[Reports]![RptInvoice]![cltIdcard]) AND ((tblHospitalisations.invoiced)=false));"
DoCmd.RunSQL StrSQL
'mark the tblservicelog as invoiced and add invoice no
StrSQL = "UPDATE tblservicelog SET tblservicelog.invoiceno =[Forms]![frmBilling]![paste_invoiceno] , tblservicelog.invoiced = true" _
& " WHERE (((tblservicelog.invoiced)=false) AND ((tblservicelog.hospno)=[Reports]![RptInvoice]![cltIdcard]));"
DoCmd.RunSQL StrSQL
'mark the tblinvestigations as invoiced and add invoiceno
StrSQL = "UPDATE tblTest INNER JOIN tblClinPict ON tblTest.IDClinPict = tblClinPict.ID SET tblTest.Invoiceno = [Forms]![frmBilling]![paste_invoiceno], tblTest.Invoiced = true" _
& " WHERE (((tblTest.Invoiced)=false) AND ((tblClinPict.CltID)=[Reports]![RptInvoice]![cltIdcard]));"
DoCmd.RunSQL StrSQL
Me.paste_invoiceno.Value = 0
Me.Requery
End Sub
When I run it with a 'toggle breakpoint' and using F8, it runs well and the InVAmount field in the table tblInvoices fills well according to the amount on the report field (TotalSum).
When the vba code is running alone without a breakpoint the InVAmount on tblInvoices always fills up with '0'.
Is there an explanation for this ?
Many thanks.
LouisB
Last edited: