ð Master Visual Basic .NET and Access Database By Building the Point Of Sale System (POS).
ðē Enroll Now: https://bit.ly/2WcbRhX
Access VBA Programming : How to Create Search Form Using Text Box.
- Table
- Form
- Module
- VBA Code
How to Create Search Form Part 2
Open Form To Selected Record From List Box.
- Table
- Form
- Module
- VBA Code
How to Create Search Form Part 1
How to Create Search Form Part 2
Open Form To Selected Record From List Box.
[Source Code]
‘--strMod (Module)
Option Compare Database
Global strRowsource As String
‘—Form1
Option Compare Database
Private Sub cmdClose_Click()
DoCmd.Close acForm, "Form1"
'Close Form1
End Sub
Private Sub Form_Load()
txtSearch.SetFocus
End Sub
Private Sub Frame1_AfterUpdate()
txtSearch = ""
txtSearch.SetFocus
End Sub
Private Sub List1_DblClick(Cancel As Integer)
Dim RowNumber As Integer
RowNumber = Me.List1.ListIndex + 1
Dim varID, varName, varJob, varCity
varID = (List1.Column(0, RowNumber))
varName = (List1.Column(1, RowNumber))
varJob = (List1.Column(2, RowNumber))
varCity = (List1.Column(3, RowNumber))
Dim Response As Integer
Response = MsgBox("detail" & vbCrLf & _
"------" & vbCrLf & _
"ID : " & varID & vbCrLf & _
"Name : " & varName & vbCrLf & _
"Job : " & varJob & vbCrLf & _
"City : " & varCity & "." & vbCrLf & vbCrLf & _
"For more information, click OK", vbOKCancel, "Customer Information")
If Response = vbOK Then
DoCmd.OpenForm "frmCustInfo", , , "[ID] = " & List1.Column(0)
Forms![frmCustInfo].ID.BorderColor = vbRed
Forms![frmCustInfo].ID.Enabled = False
Forms![frmCustInfo].ID.Locked = True
Else
End If
End Sub
Private Sub txtSearch_Change()
If Frame1 = 1 Then 'Name
strRowsource = "SELECT [ID], [Customer Name], [Job Title], City " & "FROM Customers " & _
"WHERE [Customer Name] Like '*" & Me.txtSearch.Text & "*' "
ElseIf Frame1 = 2 Then 'Job
strRowsource = "SELECT [ID], [Customer Name], [Job Title], City " & "FROM Customers " & _
"WHERE [Job Title] Like '*" & Me.txtSearch.Text & "*' "
Else 'City
strRowsource = "SELECT [ID], [Customer Name], [Job Title], City " & "FROM Customers " & _
"WHERE City Like '*" & Me.txtSearch.Text & "*' "
End If
List1.RowSource = strRowsource
End Sub
Private Sub txtSearch_Click()
strRowsource = "SELECT [ID], [Customer Name], [Job Title], City " & "FROM Customers"
List1.RowSource = strRowsource
End Sub
‘—frmCustInfo (Form)
Option Compare Database
Private Sub Form_Load()
txtFucus.SetFocus
End Sub
My Twitter
My Facebook
My Google+
My YouTube Channel
Thank you very much.
āļāļāļāļุāļāļāļĢัāļ.
Comments
Post a Comment