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. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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
|
|||
|
|||
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 | |
|
|