Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 41
Default v lookup problem

Greeting,
I have an excel sheet for inputting employees data. In this sheet there is a
command to open a form to input data and there is a textbox which is employee
id. What I want to do is to check the employee id if it is already excess, a
msgbox shows and tell the user that it is already excess any should be
change. There is a problem with my code but I don't where it is.
Can any body help me please?

Private Sub TextBox3_Change()
If Not IsNull(vLookup("[ID]", "[Data]", "[ID] = " & [TextBox3])) Then

MsgBox "Sorry€¦ the ID is already input please reenter the Id " _
, vbOKOnly + vbCritical, _
"Duplicated ID"

DoCmd.CancelEvent

End If

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default v lookup problem

Are you sure you didn't want to post this question in an Access forum?

That DoCmd doesn't look like excel...

But if you really meant excel...

Option Explicit
Private Sub TextBox3_Change()

dim Res as variant
dim RngToCheck as range

with worksheets("somesheetnamehere")
set rngtocheck = .range("a1",.cells(.rows.count,"A").end(xlup))
end with

res = application.match(textbox3.value, rngtocheck, 0)

if iserror(res) then
'not found
else
'it matched
end if

End Sub

And are you really sure you want this to run with each change to the textbox?



ghost wrote:

Greeting,
I have an excel sheet for inputting employees data. In this sheet there is a
command to open a form to input data and there is a textbox which is employee
id. What I want to do is to check the employee id if it is already excess, a
msgbox shows and tell the user that it is already excess any should be
change. There is a problem with my code but I don't where it is.
Can any body help me please?

Private Sub TextBox3_Change()
If Not IsNull(vLookup("[ID]", "[Data]", "[ID] = " & [TextBox3])) Then

MsgBox "Sorry€¦ the ID is already input please reenter the Id " _
, vbOKOnly + vbCritical, _
"Duplicated ID"

DoCmd.CancelEvent

End If


--

Dave Peterson
Reply
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
Lookup problem Esseja Excel Worksheet Functions 4 January 31st 09 10:31 AM
lookup problem. MyFairLady Excel Worksheet Functions 3 January 31st 07 10:33 PM
LookUp Problem LostNFound Excel Worksheet Functions 2 October 13th 06 06:18 AM
LOOKUP problem pdgaustintexas Excel Worksheet Functions 2 January 19th 06 03:39 PM
Lookup Problem StephanieH Excel Worksheet Functions 1 December 20th 04 06:17 PM


All times are GMT +1. The time now is 06:52 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"