Hi there
I am trying to learn Access during my free time, to learn something
I learn a lot through this web form
Anyways, here's my situation, I am getting following error
"MS Access can't find the field "|" referred in your expression"
I am trying to validate the field behaviour before SAVE
Instead of writing a code at each textbox, I am trying to use WHILE LOOP
There're 12 textbox and 3 validations at each textbox
1) Can't Empty
2) If Combo box listIndex value = "1" then textbox value can't be more than 29
3) If Combo box listIndex value other than "1" then textbox value can't be more than 31
Following codes are working perfectly at individual textbox level
However, when I use with WHILE LOOP, getting error message
"MS Access can't find the field "|" referred in your expression"
Dim count1 As Integer
Dim check1 As Integer
count1 = 1
While count1 < 13
Me.[txtbox" & count1 & "].SetFocus
If Me.[combox" & count1 & "].ListIndex = 1 Then
If Me.[txtbox" & count1 & "] > 29 Then
check1 = check1 + 1
MsgBox "Validation Option 2", vbInformation, "Error"
Me.[txtbox" & count1 & "].SetFocus
Exit Sub
End If
Else
If Me.[txtbox" & count1 & "] > 31 Then
check1 = check1 + 1
MsgBox "Validation Option 3", vbInformation, "Error"
Me.[txtbox" & count1 & "].SetFocus
Exit Sub
End If
End If
Me.[txtbox" & count1 & "].SetFocus
If IsNull([txtbox" & count1 & "]) = True Then
check1 = check1 + 1
MsgBox "Validation Option 1", vbInformation, "Error"
Me.[txtbox" & count1 & "].SetFocus
Exit Sub
End If
count1 = count1 + 1
Wend
Thanks for any help in advance
I am trying to learn Access during my free time, to learn something
I learn a lot through this web form
Anyways, here's my situation, I am getting following error
"MS Access can't find the field "|" referred in your expression"
I am trying to validate the field behaviour before SAVE
Instead of writing a code at each textbox, I am trying to use WHILE LOOP
There're 12 textbox and 3 validations at each textbox
1) Can't Empty
2) If Combo box listIndex value = "1" then textbox value can't be more than 29
3) If Combo box listIndex value other than "1" then textbox value can't be more than 31
Following codes are working perfectly at individual textbox level
However, when I use with WHILE LOOP, getting error message
"MS Access can't find the field "|" referred in your expression"
Dim count1 As Integer
Dim check1 As Integer
count1 = 1
While count1 < 13
Me.[txtbox" & count1 & "].SetFocus
If Me.[combox" & count1 & "].ListIndex = 1 Then
If Me.[txtbox" & count1 & "] > 29 Then
check1 = check1 + 1
MsgBox "Validation Option 2", vbInformation, "Error"
Me.[txtbox" & count1 & "].SetFocus
Exit Sub
End If
Else
If Me.[txtbox" & count1 & "] > 31 Then
check1 = check1 + 1
MsgBox "Validation Option 3", vbInformation, "Error"
Me.[txtbox" & count1 & "].SetFocus
Exit Sub
End If
End If
Me.[txtbox" & count1 & "].SetFocus
If IsNull([txtbox" & count1 & "]) = True Then
check1 = check1 + 1
MsgBox "Validation Option 1", vbInformation, "Error"
Me.[txtbox" & count1 & "].SetFocus
Exit Sub
End If
count1 = count1 + 1
Wend
Thanks for any help in advance