I am totally new to the VBA and I have following problem.
I have two tables
Holderdata : Parent ; Purchasedata : child
I created a search form based on holder data. the search criteria (User input) is "Lastname". I want to show the search results based on lastname from holder data in mainform and relative purchasedata from purchasedata to the subform.
I have to commands called search and resetsearch. Search is working. For resetsearch I want to clear the "searchbylastna me" textbox as well as all the fields on mainfrom and subform.
Here is all my code
Please help!!
[CODE=vb]
Dim strsql As String
Dim strlname As String
Dim strwhere As String
Dim lnglen As Long
Private Sub form_load()
Me.filter = "(False)"
Me.FilterOn = True
End Sub
Private Sub cmdsearch_Click ()
subfrmsearchbyl name.Locked = True
txtfirstname.Lo cked = True
txtlastname.Loc ked = True
txtmi.Locked = True
txtaddress.Lock ed = True
txtaddress2.Loc ked = True
txtzipcode.Lock ed = True
txtcity.Locked = True
txtstate.Locked = True
txttelephone.Lo cked = True
txtbdate.Locked = True
txtdeceased.Loc ked = True
txtheight.Locke d = True
txtweight.Locke d = True
txtheducation.L ocked = True
txteyecolor.Loc ked = True
txthaircolor.Lo cked = True
txtcstate.Locke d = True
txtsex.Locked = True
txtfirstname.En abled = False
If Not IsNull(Me.txten terlname) Then
strwhere = strwhere & "([LAST_NAME] = """ & Me.txtenterlnam e & """) And "
End If
lnglen = Len(strwhere) - 5
If lnglen <= 0 Then
MsgBox "Nothing is specified", vbInformation, "Nothing to Show"
Else
strwhere = Left$(strwhere, lnglen)
Me.filter = strwhere
Me.FilterOn = True
End If
End Sub
Private Sub cmdReset_Click( )
'Purpose: Clear all the search boxes and show all records again.
Dim ctl As Control
'Clear all the controls in the Form
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acTextBox
ctl.Enabled = False
End Select
Next
'Remove the form's filter.
Me.FilterOn = False
End Sub[/CODE]
I have two tables
Holderdata : Parent ; Purchasedata : child
I created a search form based on holder data. the search criteria (User input) is "Lastname". I want to show the search results based on lastname from holder data in mainform and relative purchasedata from purchasedata to the subform.
I have to commands called search and resetsearch. Search is working. For resetsearch I want to clear the "searchbylastna me" textbox as well as all the fields on mainfrom and subform.
Here is all my code
Please help!!
[CODE=vb]
Dim strsql As String
Dim strlname As String
Dim strwhere As String
Dim lnglen As Long
Private Sub form_load()
Me.filter = "(False)"
Me.FilterOn = True
End Sub
Private Sub cmdsearch_Click ()
subfrmsearchbyl name.Locked = True
txtfirstname.Lo cked = True
txtlastname.Loc ked = True
txtmi.Locked = True
txtaddress.Lock ed = True
txtaddress2.Loc ked = True
txtzipcode.Lock ed = True
txtcity.Locked = True
txtstate.Locked = True
txttelephone.Lo cked = True
txtbdate.Locked = True
txtdeceased.Loc ked = True
txtheight.Locke d = True
txtweight.Locke d = True
txtheducation.L ocked = True
txteyecolor.Loc ked = True
txthaircolor.Lo cked = True
txtcstate.Locke d = True
txtsex.Locked = True
txtfirstname.En abled = False
If Not IsNull(Me.txten terlname) Then
strwhere = strwhere & "([LAST_NAME] = """ & Me.txtenterlnam e & """) And "
End If
lnglen = Len(strwhere) - 5
If lnglen <= 0 Then
MsgBox "Nothing is specified", vbInformation, "Nothing to Show"
Else
strwhere = Left$(strwhere, lnglen)
Me.filter = strwhere
Me.FilterOn = True
End If
End Sub
Private Sub cmdReset_Click( )
'Purpose: Clear all the search boxes and show all records again.
Dim ctl As Control
'Clear all the controls in the Form
For Each ctl In Me.Controls
Select Case ctl.ControlType
Case acTextBox
ctl.Enabled = False
End Select
Next
'Remove the form's filter.
Me.FilterOn = False
End Sub[/CODE]
Comment