Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Open Different Form

Status
Not open for further replies.

xeb

Technical User
Nov 14, 2003
81
US
Hi:

I'm building a MS Access database for an easter egg hunt. The kids will find codes in their eggs which they will then input into the program. After they enter their code in the "Enter Paramater Value" box I now have it so it goes to a form saying they won which works fine. I wanted to use a report but I guess you can't have a flashing text box (for congratulations) in a report. Is that correct? I'd like to have some codes that aren't winners, in which case I'd like a different form or report to appear, one that would say "sorry", try again" or something like that. Is it possible when the code entered is not in the table that it will open a different form or report or is there a better way to do it?

Thanks,

xeb
 
A message box or a form styled as messgebox more style design?
Code below can be used for a form enabled with timer and on timer label will blink.

Code:
Private Sub Form_Timer()
If Me.Label0.BackColor = vbBlack Then
	Me.Label0.BackColor = vbRed
	Beep
Else
	Me.Label0.BackColor = vbBlack
End If
End Sub
Control the caption of the label depending to win/loose form the main form
hope this helps

Zameer Abdulla
Jack of Visual Basic Programming, Master in Dining & Sleeping
Visit Me
 
Hi:

Thanks for answering but I'm still fairly new at this so I don't fully understand what you've suggested. Could you explain it a little more please.

Thanks,

xeb
 
Some how you are gertting the result if the kid win or not right?
You have to create a small form looks like a message box with its timer enabled. If a kid win the let the new form popup with blinking label & caption "Winner" or something like. If he/she loose then same form will popup with label caption changed to "Sorry Try again".
Reports are used to print data for display use forms.
hope this helps

Zameer Abdulla
Jack of Visual Basic Programming, Master in Dining & Sleeping
Visit Me
 
Hi:

I still need help with this.

I didn't mention that the codes and the prizes are in a table that I want to pass on to the form. In other words, when a kid inputs a code it matches that code with the one in the table and returns that they've won. So I don't see how what has been suggested will work.

Thanks,

xeb
 
Your table will have some fields like
[ul]
[li] Question [/li]
[li] Answer [/li]
[li] some other info[/li]
[/ul]
All the fields will be displayed on the form except the answer. You will have an empty field to input the answer. So once the kid input the answer & click a button do a search in the table to match the answer with the question using the DLookup Function. If the answer matches with question then the popup form will come up with message that he won or it will come with the lost message.
Do a search in the help file for more about the DLookup function. It will be some thing like below.

Code:
DLookup("[Answer]", "QuestionTable", "[Answer] = " & Me.AnswerField.Value)
Hope this helps

Zameer Abdulla
Jack of Visual Basic Programming, Master in Dining & Sleeping
Visit Me
 
There is another way. Your form will be having all fields and the answer field will be Visible=False
Place a TextBox on the form name it "txtAnswer"
a command button "cmdTest"

Code:
Private Sub cmdTest_Click()
If Me.[COLOR=navy]AnswerField[/color].Value = Me.txtAnswer.Value Then
    DoCmd.OpenForm "FrmMessage", , , , , , "Won"
Else
    DoCmd.OpenForm "FrmMessage", , , , , , "Lost"
End If
End Sub
Create the message form(FrmMessage) with flashing label & stuff.
In the OnOpenEvent of the FrmMessage put the code below.

Code:
Private Sub Form_Open(Cancel As Integer)
Select Case Me.OpenArgs
    Case "Won"
        Me.Caption = "Hurray"
        Me.[COLOR=navy]LabelMessage[/color].Caption = "You Won"
    Case "Lost"
        Me.Caption = "OOPS...."
        Me.[COLOR=navy]LabelMessage[/color].Caption = "You Lost"
End Select
End Sub
colored items should chaged if you are changing the name of the label and command buttons

Zameer Abdulla
Jack of Visual Basic Programming, Master in Dining & Sleeping
Visit Me
 
Zameer Abdulla:

I tried for several days to get your final suggestion to work but I can't. I'm sure it's just my inexperience with Access.

Anyway, when I run it I keep getting the following two code items highlighted in yellow...

.AnswerField
.LabelMessage

Thanks,

xeb
 
Answer field is the name of the textfield where the kids enter their answers.
and LabelMessage is the name of label that displays message on the flasing form(frmMessage). You have to change their accordingly.

________________________________________
Zameer Abdulla
Visit Me
Hold your child's hand every chance you get.
A time will come when he or she won't let you.
 
Zameer Abdulla:

I've tried again for two days to get this to work but it won't.

I've got the first part working that uses this code...

Private Sub cmdTest_Click()
If Me.AnswerField.Value = Me.txtAnswer.Value Then
DoCmd.OpenForm "FrmMessage", , , , , , "Won"
Else
DoCmd.OpenForm "FrmMessage", , , , , , "Lost"
End If
End Sub

However, when I add the second part with the other code it stops on these items highlighted in yellow...

.AnswerField
.LabelMessage

Also, is there a way for your method to work with a query?

When I test the first part it works fine, but only for the record selected. I need a query to find or try to find the matching code in the table.

Thanks,

xeb
 
I have made an update on the db. Now the zip file 19kb.
Please have a look at it.

________________________________________
Zameer Abdulla
Visit Me
Hold your child's hand every chance you get.
A time will come when he or she won't let you.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top