swift_electrical
New member
- Local time
- Today, 10:20
- Joined
- Apr 9, 2013
- Messages
- 7
Hi,
I have a customer database running in Microsoft Access and at the moment in the design view I have created another text field so I can look up customers via a Post Code as at the moment I can only look up via Customer Name.
I have created a new textfield called (txtpostcode) but I need to change the search button function to allow the text field to be looked up as its only looking up (txtCustomer).
Code as follows:
I'm looking to add a section like this:-
Any help would be great!
I have a customer database running in Microsoft Access and at the moment in the design view I have created another text field so I can look up customers via a Post Code as at the moment I can only look up via Customer Name.
I have created a new textfield called (txtpostcode) but I need to change the search button function to allow the text field to be looked up as its only looking up (txtCustomer).
Code as follows:
Code:
Option Compare Database
Option Explicit
Private Sub Command7_Click()
End Sub
Private Sub cmdFind_Click()
On Error GoTo Err_cmdFind_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim custid
stDocName = "Customers"
If Not IsNull(txtInvoice) Then
If LCase(Left(txtInvoice, 1)) = "s" Then
Dim SaleID
SaleID = Mid(txtInvoice, 2)
custid = DLookup("CustomerID", "Sales", "SaleID=" & SaleID)
Else
Dim RepairID
RepairID = Mid(txtInvoice, 2)
custid = DLookup("CustomerID", "Repairs", "RepairID=" & RepairID)
End If
If Not IsNull(txtPostcode) Then
If LCase(Left(txtPostcode, 1)) = "s" Then
Dim SaleID
SaleID = Mid(txtPostcode, 2)
custid = DLookup("CustomerID", "Sales", "SaleID=" & SaleID)
Else
Dim RepairID
RepairID = Mid(txtPostcode, 2)
custid = DLookup("CustomerID", "Repairs", "RepairID=" & RepairID)
End If
If IsNull(custid) Then
custid = 0
End If
stLinkCriteria = "[CustomerID] = " & custid
Else
stLinkCriteria = "[Name] Like '*" & Me![txtCustomer] & "*'"
End If
Me![subform].Form.Filter = stLinkCriteria
Me![subform].Form.FilterOn = True
'DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_cmdFind_Click:
Exit Sub
Err_cmdFind_Click:
MsgBox Err.Description
Resume Exit_cmdFind_Click
End Sub
Private Sub cmdAdmin_Click()
On Error GoTo Err_cmdAdmin_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "Parameters"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Exit_cmdAdmin_Click:
Exit Sub
Err_cmdAdmin_Click:
MsgBox Err.Description
Resume Exit_cmdAdmin_Click
End Sub
I'm looking to add a section like this:-
Code:
stLinkCriteria = "[Postcode] Like '*" & Me![txtpostcode] & "*'"
Any help would be great!