Checking Yes or No before going to Form

L

learning_codes

Hi,

I'm getting frustrated. I did ok but trying to alert either way if
the records are completed then go to the report areas but if the
records are not completed and advise that there are outstanding
records that need to be done before going to reports.

If you have a better suggestion or easy way to do this, I would
appreciate your help. I'm still learning.


***************************

Dim....

strDocName = " go to form "
strDocName2 = " Report Ment


If ([Notification] = "NO") Then

MsgBox " You did not complete the questions "

strLastname ="= ' " & Me.LastName & " ' "

strCriteria =" [tbl_Players] " & strLastname
DoCmd.OpenForm stDocName, , , strCriteria

Exit Sub
End if

If ([Notification] = "YES") Then

MsgBox " Thank you for completing the questions"

strLastname ="= ' " & Me.LastName & " ' "

strCriteria =" [tbl_Players] " & strLastname
DoCmd.Openform stDocName2, , , strCriteria

Exit Sub
End if

*************************************************
 
J

John W. Vinson

Hi,

I'm getting frustrated. I did ok but trying to alert either way if
the records are completed then go to the report areas but if the
records are not completed and advise that there are outstanding
records that need to be done before going to reports.

If you have a better suggestion or easy way to do this, I would
appreciate your help. I'm still learning.


***************************

Dim....

strDocName = " go to form "
strDocName2 = " Report Ment

If the above is your actual code it's not making sense. There's no close quote
on the second line; the leading and trailing blanks won't work with form or
report names.
If ([Notification] = "NO") Then

What is the datatype of [Notification]? If it's a yes/no field then it is NOT
a text string and it will never be set to the text string "NO". And how does
answering the questions affect the value of [Notification]?
MsgBox " You did not complete the questions "

strLastname ="= ' " & Me.LastName & " ' "

strCriteria =" [tbl_Players] " & strLastname

Why the extra variable and extra step?

strCriteria = "[LastName] = """ & Me!LastName & """"

using the fieldname (which you can search) rather than the tablename (which
you can't), and doublequote delimiters rather than singlequote delimiters
which will fail with a LastName such as O'Brien.
DoCmd.OpenForm stDocName, , , strCriteria

Exit Sub
End if

If ([Notification] = "YES") Then

An Else statement rather than an End If and another If will work here, and be
simpler.
MsgBox " Thank you for completing the questions"

strLastname ="= ' " & Me.LastName & " ' "

strCriteria =" [tbl_Players] " & strLastname
DoCmd.Openform stDocName2, , , strCriteria

If you're trying to open a Report, use OpenReport rather than OpenForm.
Exit Sub
End if

*************************************************

John W. Vinson [MVP]
 
L

learning_codes

I'm getting frustrated. I did ok but trying to alert either way if
the records are completed then go to the report areas but if the
records are not completed and advise that there are outstanding
records that need to be done before going to reports.
If you have a better suggestion or easy way to do this, I would
appreciate your help. I'm still learning.


strDocName = " go to form "
strDocName2 = " Report Ment

If the above is your actual code it's not making sense. There's no close quote
on the second line; the leading and trailing blanks won't work with form or
report names.


If ([Notification] = "NO") Then

What is the datatype of [Notification]? If it's a yes/no field then it is NOT
a text string and it will never be set to the text string "NO". And how does
answering the questions affect the value of [Notification]?
MsgBox " You did not complete the questions "
strLastname ="= ' " & Me.LastName & " ' "
strCriteria =" [tbl_Players] " & strLastname

Why the extra variable and extra step?

strCriteria = "[LastName] = """ & Me!LastName & """"

using the fieldname (which you can search) rather than the tablename (which
you can't), and doublequote delimiters rather than singlequote delimiters
which will fail with a LastName such as O'Brien.
DoCmd.OpenForm stDocName, , , strCriteria
Exit Sub
End if
If ([Notification] = "YES") Then

An Else statement rather than an End If and another If will work here, and be
simpler.
MsgBox " Thank you for completing the questions"
strLastname ="= ' " & Me.LastName & " ' "
strCriteria =" [tbl_Players] " & strLastname
DoCmd.Openform stDocName2, , , strCriteria

If you're trying to open a Report, use OpenReport rather than OpenForm.
Exit Sub
End if
*************************************************

John W. Vinson [MVP]- Hide quoted text -

- Show quoted text -

Thanks,

I did not use yes/no. I use the text field if Yes or No to help me
which one
to go the form (2 forms).

I guess it will not work on from. Is that correct ?

Thanks
 
J

John W. Vinson

I did not use yes/no. I use the text field if Yes or No to help me
which one
to go the form (2 forms).

I guess it will not work on from. Is that correct ?

Well, your code as written evidently will not work because it doesn't work.
But since I do not know anything about your form names, how the form is
structured, your fieldnames, etc. I cannot immediately help you get it to
work.

But yes - with correctly written code, you CAN use a text value in a textbox
to decide which form to open.

Please post some more details (the actual names of the forms for example) and
I'll try to help.

John W. Vinson [MVP]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top