LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Report Post  
Posted to microsoft.public.access.modulesdaovba,microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default validating against a list - Please Help!

?B?ZGNz?= wrote in
:

For instance, my valid numbers list is 800000001-800000999 and when
800000235 is eneterd it is determined to be valid, however I do not
want that exact number to be allowed again.


All on one line:

= DCount("*","ValidNumbers","IDNumber = " & SuggestedNumber) 0 AND _
DCount("*","ActualTable","IDNumber = " & SuggestedNumber) = 0


This works if (a) you delete records from ActualTable and (b) you are
allowed to re-use the numbers. If you don't want to re=use them, you need

= DCount("*", "ValidNumbers", _
"IDNumber = " & SuggestedNumber & " AND Used = False")

but if you have multiple users you run the risk of reading the value twice
and trying to use it twice (IYSWIM). In that case you have to set the flag
before using it:

strSQL = "UPDATE ValidNumbers SET Used = TRUE " & _
"WHERE IDNumber = " & SuggestedNumber

db.Execute strSQL, dbFailOnError

If db.RecordsAffected = 0 Then
MsgBox "That number was not available"

Else
' It was okay

End If

Hope that helps (PS I have not tested any of this code!!)

Tim F


 
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
validating Philashley Excel Discussion (Misc queries) 2 March 13th 08 03:54 PM
vlookup and validating data list Donna Excel Worksheet Functions 11 February 29th 08 06:05 AM
Modifying a validating list [email protected] Excel Discussion (Misc queries) 1 January 25th 07 12:34 AM
validating a list of multiple columns grumpy Excel Worksheet Functions 1 December 19th 06 06:27 AM
Validating Sdbenn90 Excel Discussion (Misc queries) 0 March 27th 06 12:05 AM


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