A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Database Design
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Random number query question



 
 
Thread Tools Display Modes
  #11  
Old January 8th, 2009, 01:52 AM posted to microsoft.public.access.tablesdbdesign
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Random number query question

On Wed, 7 Jan 2009 16:30:07 -0800, Bob Waggoner
wrote:

Sorry it took so long for me to get back to you on this. The holidays & All...
I have this in my query - with the function you wrote earlier in the modules
tab.

Shuffle: RndNum([ValidationNum])
The problem is, I get "compile error in query expression
'RndNum([validationNum])'"

Here's the code in the module:
Public Function RndNum(vIgnore As Variant) As Double
Static bRnd As Boolean
If Not bRnd Then
'Initialize the random number generator once only
bRnd = True
Randomize
End If
RndNum = Rnd()
End Function


Open the module in the VBA editor. Select Debug... Compile my database.

Do you get an error message? If so on what line, and what's the error?
--

John W. Vinson [MVP]
  #12  
Old January 8th, 2009, 01:41 PM posted to microsoft.public.access.tablesdbdesign
Bob Waggoner[_2_]
external usenet poster
 
Posts: 80
Default Random number query question

John,
I'd really like to shake your hand. Thanks for being so insightful. It
worked. I had a few compile errors that needed to be cleaned up. The problem
with this particular code was the lack of ' in front of comments. I should'a
known better. Anyway, thanks!

"John W. Vinson" wrote:

On Wed, 7 Jan 2009 16:30:07 -0800, Bob Waggoner
wrote:

Sorry it took so long for me to get back to you on this. The holidays & All...
I have this in my query - with the function you wrote earlier in the modules
tab.

Shuffle: RndNum([ValidationNum])
The problem is, I get "compile error in query expression
'RndNum([validationNum])'"

Here's the code in the module:
Public Function RndNum(vIgnore As Variant) As Double
Static bRnd As Boolean
If Not bRnd Then
'Initialize the random number generator once only
bRnd = True
Randomize
End If
RndNum = Rnd()
End Function


Open the module in the VBA editor. Select Debug... Compile my database.

Do you get an error message? If so on what line, and what's the error?
--

John W. Vinson [MVP]

  #13  
Old January 8th, 2009, 05:52 PM posted to microsoft.public.access.tablesdbdesign
John W. Vinson
external usenet poster
 
Posts: 18,261
Default Random number query question

On Thu, 8 Jan 2009 05:41:00 -0800, Bob Waggoner
wrote:

John,
I'd really like to shake your hand. Thanks for being so insightful. It
worked. I had a few compile errors that needed to be cleaned up. The problem
with this particular code was the lack of ' in front of comments. I should'a
known better. Anyway, thanks!


Glad I was able to point you in the right direction; good luck!
--

John W. Vinson [MVP]
 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 02:12 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.