Help with code

G

Guest

Access 2000. I need help with this code. When a button is pressed. A
diolog box pops up asking for "EnterDateIssued" where the user would enter a
date. If the user forgets to enter a date and clicks "OK" a report is
printed with the date missing. I need something in the code that will
prevent the report from being printed unless the date is entered. I know
this is easy to you Access experts. Thanks, Randy.
 
G

Guest

Access 2000. I need help with this code. When a button is pressed. A
diolog box pops up asking for "EnterDateIssued" where the user would enter
a date. If the user forgets to enter a date and clicks "OK" a report is
printed with the date missing. I need something in the code that will
prevent the report from being printed unless the date is entered. I know
this is easy to you Access experts. Thanks, Randy.

Private Sub Summary_with_date_issued_Click()
On Error GoTo Err_Summary_with_date_issued_Click
Dim stDocName As String
Dim strWhere As String
DoCmd.SetWarnings False
If Me.Dirty Then 'Save any edits first.
Me.Dirty = False
End If
If Me.NewRecord Then
MsgBox "Field Note Not Selected. Please Select a Field Note To
Print"

Else

stDocName = "InsertDateIssued"
DoCmd.OpenQuery stDocName

stDocName = "Summary by Certificate Number"
DoCmd.OpenReport stDocName, acViewNormal, , strWhere


Exit_Summary_with_date_issued_Click:
Exit Sub

Err_Summary_with_date_issued_Click:

Resume Exit_Summary_with_date_issued_Click
DoCmd.SetWarnings True
End If

End Sub
 
J

John W. Vinson

Access 2000. I need help with this code. When a button is pressed. A
diolog box pops up asking for "EnterDateIssued" where the user would enter a
date. If the user forgets to enter a date and clicks "OK" a report is
printed with the date missing. I need something in the code that will
prevent the report from being printed unless the date is entered. I know
this is easy to you Access experts. Thanks, Randy.

Care to post your code? We can't see it from here.

You'll need to check for a NULL value in the date prior to opening the report.
 
J

John W. Vinson

Here it is again, Thanks

You had started a new thread rather than replying in the existng thread, so
other than doing a (rather vague) search for previous posts by "Randy" there
was no way to easily find the previous discussion. You're not the only person
asking questions here, by a long shot!

You posted:

Private Sub Summary_with_date_issued_Click()
On Error GoTo Err_Summary_with_date_issued_Click
Dim stDocName As String
Dim strWhere As String
DoCmd.SetWarnings False
If Me.Dirty Then 'Save any edits first.
Me.Dirty = False
End If
If Me.NewRecord Then
MsgBox "Field Note Not Selected. Please Select a Field Note To
Print"

Else

stDocName = "InsertDateIssued"
DoCmd.OpenQuery stDocName

' MY QUESTION:
What is InsertDateIssued? An APpend query, an Update query, what? What is it
inserting and where?

You may be able to use the querydef Execute method instead if you just want to
determine whether a new record was created. But since - again - you didn't
post the information about your database, and since as an unpaid volunteer
it's more than I'm comfortable doing to google for your previous messages, I
really don't know.

--

John W. Vinson [MVP]

stDocName = "Summary by Certificate Number"
DoCmd.OpenReport stDocName, acViewNormal, , strWhere


Exit_Summary_with_date_issued_Click:
Exit Sub

Err_Summary_with_date_issued_Click:

Resume Exit_Summary_with_date_issued_Click
DoCmd.SetWarnings True
End If

End Sub
 
R

Randy

Wow! Are you having a bad day? I dont have a clue what your problem is.
Thanks for nothing!
 
R

Rui

I think I can understand John;'s rationale for asking that question.

It looks from the code that you are actually running a query and that it is
that query that is 'asking for the date'. If this is so, then you may need to
alter that.

Otherwise, I would just add a check to the biginning of the Sub
Summary_with_date_issued_Click(). Check that the text field for the date is
not empty and if so, then exit sub (or notify user and exit sub).

Hope this helps
 
G

Guest

Thank you very much. Thant helped a lot.
Rui said:
I think I can understand John;'s rationale for asking that question.

It looks from the code that you are actually running a query and that it
is
that query that is 'asking for the date'. If this is so, then you may need
to
alter that.

Otherwise, I would just add a check to the biginning of the Sub
Summary_with_date_issued_Click(). Check that the text field for the date
is
not empty and if so, then exit sub (or notify user and exit sub).

Hope this helps
 

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