LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Validate data in userform data entry


Hi,

Trying to check if data entered in TextBox1 is a valid entry by looking
up a database and returning data into the userform. The "testid' is the
first column in the database and is sorted.

My code is as follows and I continue to receive the error message even
if the data entered in TextBox1 is valid.

Can anyone help please.


Private Sub TextBox1_AfterUpdate()

Sheets("Menu").Select
Range("Testid") = TextBox1.Value

If Range("Testid").FormulaR1C1 =
"=VLOOKUP(TextBox1.Value,TestDB,1,FALSE))" = False Then
MsgBox "Test ID does not exist! Either correct the number entered
or create a new Database record", vbOK, "Error message"
TextBox2.Value = ""
TextBox3.Value = ""
TextBox4.Value = ""
TextBox1.SetFocus

Exit Sub

Else
Range("Number").FormulaR1C1 =
"=if(testid="""","""",VLOOKUP(testID,testDB,2,FALS E))"
Range("Surname").FormulaR1C1 =
"=if(testid="""","""",VLOOKUP(testID,testDB,3,FALS E))"
Range("FirstName").FormulaR1C1 =
"=If(testid="""","""",VLOOKUP(testID,testDB,4,FALS E))"
End If

End Sub


--
BernzG
------------------------------------------------------------------------
BernzG's Profile: http://www.excelforum.com/member.php...o&userid=22949
View this thread: http://www.excelforum.com/showthread...hreadid=375335

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Validate data but then change the entry to upper case Ephraim Excel Worksheet Functions 4 March 20th 10 06:04 PM
Code/Function to Look at Previous Entry to Validate Data Steve Excel Worksheet Functions 6 February 9th 09 07:06 AM
How to validate email address during data entry in Excel Ramiro Excel Discussion (Misc queries) 1 January 20th 09 08:30 PM
Validate in WS to prevent dual data entry Jonah Excel Worksheet Functions 1 March 10th 06 05:22 AM
Validate MsgBox Entry to Data in Cells David Excel Discussion (Misc queries) 13 December 21st 05 10:31 PM


All times are GMT +1. The time now is 05:21 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"