Clear sub form at the time of opening the main form

antonio.manoj.derose

Registered User.
Local time
Tomorrow, 05:02
Joined
Jul 4, 2013
Messages
62
Hi Folks,
I have a form, which is comprised of a sub form, and some of the text box controls sided with a button, and the event had been written to the button.
Now, to give a note on how had the sub form had been created is firstly taking a clone of the ‘Payments’ table and using it as a datasheet, and then create a sub form in the form, it works fine
My query or the worry that I have to astonish is to clear the contents in the sub form, at the time of loading first
I have pasted the coding that I have done so far, but have tried googling in search of clear sub forms, but no joy, could you guys help me

Thanks,

Antonio
 
I have not pasted the code, here you go

Private Sub BtnSearch_Click()
Dim strSQL As String
Dim db As Database
Dim qDef As QueryDef
Set db = CurrentDb()
Set qDef = db.QueryDefs("qry_btn_search_payments")
If IsNull(Me.txtInvoiceNumber) And IsNull(Me.txtPremiseCode) Then
MsgBox "You need to fill up at least 1 search parameter."
Exit Sub
End If
strSQL = "SELECT P.* FROM P p where p.payment_id IS NOT NULL"
If Not IsNumeric((Me.txtInvoiceNumber)) Then strSQL = strSQL + " AND p.Invoice_Number = " & Forms!Form6!txtInvoiceNumber & ""
'qDef.Sql = strSQL
Me.Payments_SubForm.Form.RecordSource = strSQL
Me.Payments_SubForm.Requery
End Sub
 
Code is not required for this. It is one of the things Access does for you automatically. The fact that it is not working tells me that the master/child links are not set correctly. They are what Access uses to sync the subform with the main form.
 

Users who are viewing this thread

Back
Top Bottom