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  

Triggering an event based on two conditions



 
 
Thread Tools Display Modes
  #1  
Old December 15th, 2008, 05:27 PM posted to microsoft.public.access.tablesdbdesign
Bob Waggoner
external usenet poster
 
Posts: 1
Default Triggering an event based on two conditions

My before update event written like this:
Private Sub SurveyNumber_BeforeUpdate(Cancel As Integer)
'320 Or 420 Or 520 Or 620 Or 311 Or 411 Or 511 Or 611 Or 365 Or 465 Or 565
Or 665 Or 382 Or 482 Or 582 Or 682 Or 303 Or 403 Or 503 Or 603 Or 351 Or 451
Or 551 Or 651 Or 379 Or 479 Or 579 Or 679 Or 371 Or 471 Or 571 Or 671 Or 331
Or 431 Or 531 Or 631 Or 358 Or 458 Or 558 Or 658
Dim validnum As Integer
validnum = 320 Or 420 Or 520 Or 620 Or 311 Or 411 Or 511 Or 611 Or 365 Or
465 Or 565 Or 665 Or 382 Or 482 Or 582 Or 682 Or 303 Or 403 Or 503 Or 603 Or
351 Or 451 Or 551 Or 651 Or 379 Or 479 Or 579 Or 679 Or 371 Or 471 Or 571 Or
671 Or 331 Or 431 Or 531 Or 631 Or 358 Or 458 Or 558 Or 658

If [SurveyNumber] validnum Then
MsgBox "Please enter a valid number to continue"
Else
MsgBox "Thanks. I'll open the survey now."
[1a].Visible = True
[2a].Visible = True
[3a].Visible = True
[4a].Visible = True
[5a].Visible = True
[6a].Visible = True
[7a].Visible = True
[8a].Visible = True
[9a].Visible = True
[10a].Visible = True
[11a].Visible = True
[12a].Visible = True



End If

End Sub

Doesn't work. I keep getting Please Enter or Thanks. It doesn't matter what
number I type in. Please help if you can tell what I'm doing wrong.
  #2  
Old December 15th, 2008, 05:36 PM posted to microsoft.public.access.tablesdbdesign
Stefan Hoffmann
external usenet poster
 
Posts: 991
Default Triggering an event based on two conditions

hi Bob,

Bob Waggoner wrpte:
Dim validnum As Integer
validnum = 320 Or 420 Or 520 Or 620 Or 311 Or 411 Or 511 Or 611 Or 365 Or
465 Or 565 Or 665 Or 382 Or 482 Or 582 Or 682 Or 303 Or 403 Or 503 Or 603 Or
351 Or 451 Or 551 Or 651 Or 379 Or 479 Or 579 Or 679 Or 371 Or 471 Or 571 Or
671 Or 331 Or 431 Or 531 Or 631 Or 358 Or 458 Or 558 Or 658

The Or is normally a logic operator returning True or False. Not an integer.

If [SurveyNumber] validnum Then

What do you like to compare?

Doesn't work. I keep getting Please Enter or Thanks. It doesn't matter what
number I type in. Please help if you can tell what I'm doing wrong.

What do you like to achive? Open the survey, when [SurveyNumber]
contains one of those values?

Where do they come from, a table?

btw, where does the structure in the numbers come from?

mfG
-- stefan --
  #3  
Old December 15th, 2008, 05:57 PM posted to microsoft.public.access.tablesdbdesign
Bob Waggoner[_2_]
external usenet poster
 
Posts: 80
Default Triggering an event based on two conditions

Thank you! This is a quick response and I appreciate it. Maybe I should
clarify my purpose instead of my attempt.

Actually, I'm using this for an employee survey. I want the employees to use
one of the numbers (drawn from a hat) to validate their participation in the
survey. It allows me to toss out surveys that someone does more than once
because they want to stack the survey. I could put the numbers in the
validation rule of the table - and that works. What I don't know how to do,
is stop the survey until the correct number is entered. I thought the best
way to do that would be using VB Code in the form.

"Stefan Hoffmann" wrote:

hi Bob,

Bob Waggoner wrpte:
Dim validnum As Integer
validnum = 320 Or 420 Or 520 Or 620 Or 311 Or 411 Or 511 Or 611 Or 365 Or
465 Or 565 Or 665 Or 382 Or 482 Or 582 Or 682 Or 303 Or 403 Or 503 Or 603 Or
351 Or 451 Or 551 Or 651 Or 379 Or 479 Or 579 Or 679 Or 371 Or 471 Or 571 Or
671 Or 331 Or 431 Or 531 Or 631 Or 358 Or 458 Or 558 Or 658

The Or is normally a logic operator returning True or False. Not an integer.

If [SurveyNumber] validnum Then

What do you like to compare?

Doesn't work. I keep getting Please Enter or Thanks. It doesn't matter what
number I type in. Please help if you can tell what I'm doing wrong.

What do you like to achive? Open the survey, when [SurveyNumber]
contains one of those values?

Where do they come from, a table?

btw, where does the structure in the numbers come from?

mfG
-- stefan --

  #4  
Old December 15th, 2008, 07:00 PM posted to microsoft.public.access.tablesdbdesign
Stefan Hoffmann
external usenet poster
 
Posts: 991
Default Triggering an event based on two conditions

hi Bob,

Bob Waggoner wrote:
Actually, I'm using this for an employee survey. I want the employees to use
one of the numbers (drawn from a hat) to validate their participation in the
survey.

Create a table, where you store these numbers.

Then you may use e.g. DCount():

If DCount("*", _
"yourTable", _
"ValidationNum = " & [SurveyNumber]) 0 Then
'make the fields visible
End If


mfG
-- stefan --
  #5  
Old December 15th, 2008, 07:39 PM posted to microsoft.public.access.tablesdbdesign
Bob Waggoner[_2_]
external usenet poster
 
Posts: 80
Default Triggering an event based on two conditions

Thank you very much! It works beautifully.
Bob

"Stefan Hoffmann" wrote:

hi Bob,

Bob Waggoner wrote:
Actually, I'm using this for an employee survey. I want the employees to use
one of the numbers (drawn from a hat) to validate their participation in the
survey.

Create a table, where you store these numbers.

Then you may use e.g. DCount():

If DCount("*", _
"yourTable", _
"ValidationNum = " & [SurveyNumber]) 0 Then
'make the fields visible
End If


mfG
-- stefan --

 




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 10:31 AM.


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