Hi All,
Hope you can help. I'm designing a frontend for users to enter specific details about a customer which will be referenced against a watchlist and i'm having trouble getting the desired response for two reasons.
a) my first case query is fine when the Case is true however the CaseElse returns a code error 91
b) should you be able to help get this working I want the responses to stack in the txtResponse field e.g "Phone Number Known, Postcode1 Not Known, Postcode2 Not Known, Reg Known
I have only managed to overwrite the message when i was using the now commented out IF statement
Hope you can help.
Garry
Hope you can help. I'm designing a frontend for users to enter specific details about a customer which will be referenced against a watchlist and i'm having trouble getting the desired response for two reasons.
a) my first case query is fine when the Case is true however the CaseElse returns a code error 91
b) should you be able to help get this working I want the responses to stack in the txtResponse field e.g "Phone Number Known, Postcode1 Not Known, Postcode2 Not Known, Reg Known
I have only managed to overwrite the message when i was using the now commented out IF statement
Hope you can help.
Garry
Code:
Private Sub cmdCheck_Click()
Dim phoneNumber As String
Dim postCode1 As String
Dim postCode2 As String
Dim reg As String
Dim phoneChk As Range
Dim postCode1Chk As Range
Dim postCode2Chk As Range
Dim regChk As Range
Dim allChk As Range
phoneNumber = txtPhone.Value
postCode1 = txtPostcode1.Value
postCode2 = txtPostcode2.Value
reg = txtReg.Value
With RecordsSheet
Set phoneChk = .Columns(1).Find(What:=phoneNumber, After:=.Cells(1, 1), LookIn:=xlValues, lookat:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
Set postCode1Chk = .Columns(2).Find(What:=postCode1, After:=.Cells(1, 2), LookIn:=xlValues, lookat:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
Set postCode2Chk = .Columns(3).Find(What:=postCode2, After:=.Cells(1, 3), LookIn:=xlValues, lookat:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
Set regChk = .Columns(4).Find(What:=reg, After:=.Cells(1, 4), LookIn:=xlValues, lookat:=xlWhole, SearchOrder:=xlByRows, SearchDirection:=xlNext, MatchCase:=False, SearchFormat:=False)
On Error Resume Next
On Error GoTo 0
Select Case phoneChk.Value
Case phoneNumber
txtResponse.Text = "Phone Number Known"
Case Else
txtResponse.Text = "Phone Not Number Known"
'Select Case postCode1Chk.Value
' Case postCode1
' txtResponse.Text = "Postcode Known"
End Select
'If Not phoneChk Is Nothing Then
'txtResponse.Text = "Phone Number Known"
'Else
'txtResponse.Text = "Phone Number Not Known"
'ElseIf Not postCode1Chk Is Nothing Then
'txtResponse.Text = "Postcode Known"
'Else
'txtResponse.Text = "Postcode Not Known"
'ElseIf Not regChk Is Nothing Then
'txtResponse.Text = "Reg Number Known"
'Else
'txtResponse.Text = "Reg Number Not Known"
'End If
End With
End Sub