Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

trying to exit Update command if textbox isn't valid 1

Status
Not open for further replies.

adddeveloper

Programmer
Dec 16, 2006
43
US
Here's my code, but it's not getting caught:

If Len(Trim(txtASBRes.Text)) > 0 And InStrtxtASBRes.Text, "|") = 0 Then

'Means there are characters for the Resource code
' and no pipecleaner = didn't use ddl for name
lblResCodeWarn.Visible = True
lblResCodeWarn.Text = "* Use list!"
Exit Sub
End If

If the user just types something in and doesn't use the autosuggest text box, then I want to tell them via a warning they need to use the values from the dropdown list. The above code isn't getting caught though.

Any suggestions are welcome!

Thanks!
 
Code:
If Len(Trim(txtASBRes.Text)) > 0 And InStrtxtASBRes.Text, "|") = 0 Then
I can't see how that would compile anyway as there is a syntax error. Maybe that is the problem?


____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
sorry...typo from my code copy:
instr(txtASBRes.Text, "|") = 0

It compiles correctly.

Thanks!
 
...and....it's my datagrid update command.

If the user tries to update a name, and doesn't use the autosuggest text box's dropdown list, then I wanna exit the sub and display the error message.
 
OK, so step throught the code and see what the following return:
Code:
Len(Trim(txtASBRes.Text))
Code:
instr(txtASBRes.Text, "|")



____________________________________________________________

Need help finding an answer?

Try the Search Facility or read FAQ222-2244 on how to get better results.

 
ca8msm,

Thanks for your patience and help!

I wasn't handling my control structure correctly.

If there was no "|", I wasn't handling it properly when I ran a database query to make sure the user didn't select a name, then try to edit it on the fly.

So, I needed to say if there's no "|" and the len() > 0, then "NO WAY" & exit the sub

else

if there is a "|" and the len() > 0, then do the db check.

Sorry for the confusion!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top