LOUISBUHAGIAR54
Registered User.
- Local time
- Today, 15:18
- Joined
- Mar 14, 2010
- Messages
- 157
I am trying to insert the rowsource property of a subform using vba, so that I can alter this accordingly.
The code goes on like this;
Private Sub cmdBilling_Click()
Dim sors As String
sors = " SELECT tblVarServices.Service, tblservicelog.invoiceno, tblservicelog.hospno, tblservicelog.ServiceRef, tblservicelog.servicedate, tblservicelog.invoiced, tblservicelog.paid, tblservicelog.item_amount, tblservicelog.itemprice, [itemprice]*[item_amount] AS Cost, tblservicelog.UserName" _
& " FROM tblVarServices INNER JOIN tblservicelog ON tblVarServices.ID = tblservicelog.ServiceRef" _
& " WHERE (((tblservicelog.Invoiced) = False))" _
& " ORDER BY tblservicelog.ID;"
If IsNull(Me.cltidcard) Then Exit Sub
DoCmd.OpenForm "FrmServices", , , acFormEdit
Forms!FrmServices.Filter = "[cltIdcard] = """ & Forms!frmClients!cltidcard & """"
Forms!FrmServices.FilterOn = True
Forms.FrmServices.FrmServicesub.Form.RowSource = sors
End Sub
However when I click the control which executes this vba sequence I get the following error message;
' Runtime error 2465;
application-defined or object-defined error.'
This error refers to the following line;
Forms.FrmServices.FrmServicesub.Form.RowSource = sors
Is this a sequenceing problem or is it a syntax error. Can I please get some help on this.
Many thanks for any help that will lead me to a solution.
LouisB
The code goes on like this;
Private Sub cmdBilling_Click()
Dim sors As String
sors = " SELECT tblVarServices.Service, tblservicelog.invoiceno, tblservicelog.hospno, tblservicelog.ServiceRef, tblservicelog.servicedate, tblservicelog.invoiced, tblservicelog.paid, tblservicelog.item_amount, tblservicelog.itemprice, [itemprice]*[item_amount] AS Cost, tblservicelog.UserName" _
& " FROM tblVarServices INNER JOIN tblservicelog ON tblVarServices.ID = tblservicelog.ServiceRef" _
& " WHERE (((tblservicelog.Invoiced) = False))" _
& " ORDER BY tblservicelog.ID;"
If IsNull(Me.cltidcard) Then Exit Sub
DoCmd.OpenForm "FrmServices", , , acFormEdit
Forms!FrmServices.Filter = "[cltIdcard] = """ & Forms!frmClients!cltidcard & """"
Forms!FrmServices.FilterOn = True
Forms.FrmServices.FrmServicesub.Form.RowSource = sors
End Sub
However when I click the control which executes this vba sequence I get the following error message;
' Runtime error 2465;
application-defined or object-defined error.'
This error refers to the following line;
Forms.FrmServices.FrmServicesub.Form.RowSource = sors
Is this a sequenceing problem or is it a syntax error. Can I please get some help on this.
Many thanks for any help that will lead me to a solution.
LouisB
Last edited: