Want to Warn Users only if the Forms Record Source is........

  • Thread starter rebecky via AccessMonster.com
  • Start date
R

rebecky via AccessMonster.com

Hi.

I have a form where the record source(query) changes based on the icon the
user selects. I have a printout button on this continuos form. When the
user is viewing the set of records on this form that includes all the records
in the database and they click the printout Icon, I want to warn them that
they are getting ready to print the entire database, vbyesno, yes = print
and no =cancel, but if the record source is a different query I want the
print out button to print out and maybe say something like "Printing Hot
Positions List"........vbokonly.

Does anyone know how to do this?

Thanks in advance for any help.....
rebecky
 
R

ruralguy via AccessMonster.com

Set a public variable when the user presses the icon. Then test the variable
when the user requests a printout.
 
R

rebecky via AccessMonster.com

Well, this is what I am using, but the Yes option and the No option produce
the same results,,,which is "Cancel".

If Me.RecordSource = "SeeAll" And MsgBox("Do You want to Print the Entire
Database?", vbYesNo, "TED version 2.1") = vbYes Then

DoCmd.PrintOut

Else
Cancel = True
End If

Set a public variable when the user presses the icon. Then test the variable
when the user requests a printout.
[quoted text clipped - 11 lines]
Thanks in advance for any help.....
rebecky
 
R

rebecky via AccessMonster.com

Oh well, I figured out something that works. Thanks for your help!
On Error GoTo Err_Command138_Click


If Me.RecordSource = "SELECT * FROM HotPositions " _
& "WHERE [open_filled] like 'open' Or [open_filled] like 'pending'" Then
MsgBox "Printing Hot Positions List", vbOKOnly, "TED version 2.1"

DoCmd.PrintOut

ElseIf Me.RecordSource = "SELECT * FROM ParkingLotEmployers " _
& "WHERE [prospect] =true" Then
MsgBox "Printing Parking Lot List", vbOKOnly, "TED version 2.1"

DoCmd.PrintOut

Else
If MsgBox("Do You want to Print the Entire Database?", vbYesNo, "TED version
2.1") = vbYes Then

DoCmd.PrintOut

Else
Cancel = True

exit_Command138_Click:
Exit Sub

Err_Command138_Click:
MsgBox "TED has Canceled the Print Job", vbOKOnly, "TED version 2.1"

Resume exit_Command138_Click

End If


End If


Well, this is what I am using, but the Yes option and the No option produce
the same results,,,which is "Cancel".

If Me.RecordSource = "SeeAll" And MsgBox("Do You want to Print the Entire
Database?", vbYesNo, "TED version 2.1") = vbYes Then

DoCmd.PrintOut

Else
Cancel = True
End If
Set a public variable when the user presses the icon. Then test the variable
when the user requests a printout.
[quoted text clipped - 4 lines]
 
R

ruralguy via AccessMonster.com

Where is your Public variable?
Well, this is what I am using, but the Yes option and the No option produce
the same results,,,which is "Cancel".

If Me.RecordSource = "SeeAll" And MsgBox("Do You want to Print the Entire
Database?", vbYesNo, "TED version 2.1") = vbYes Then

DoCmd.PrintOut

Else
Cancel = True
End If
Set a public variable when the user presses the icon. Then test the variable
when the user requests a printout.
[quoted text clipped - 4 lines]
 
R

ruralguy via AccessMonster.com

What works is a good thing. Good job.
Oh well, I figured out something that works. Thanks for your help!
On Error GoTo Err_Command138_Click

If Me.RecordSource = "SELECT * FROM HotPositions " _
& "WHERE [open_filled] like 'open' Or [open_filled] like 'pending'" Then
MsgBox "Printing Hot Positions List", vbOKOnly, "TED version 2.1"

DoCmd.PrintOut

ElseIf Me.RecordSource = "SELECT * FROM ParkingLotEmployers " _
& "WHERE [prospect] =true" Then
MsgBox "Printing Parking Lot List", vbOKOnly, "TED version 2.1"

DoCmd.PrintOut

Else
If MsgBox("Do You want to Print the Entire Database?", vbYesNo, "TED version
2.1") = vbYes Then

DoCmd.PrintOut

Else
Cancel = True

exit_Command138_Click:
Exit Sub

Err_Command138_Click:
MsgBox "TED has Canceled the Print Job", vbOKOnly, "TED version 2.1"

Resume exit_Command138_Click

End If

End If
Well, this is what I am using, but the Yes option and the No option produce
the same results,,,which is "Cancel".
[quoted text clipped - 13 lines]
 
R

rebecky via AccessMonster.com

errr,,,,I don't have one? I am a true novice and have taught myself
everything I know -which isn't a whole bunch. Never took classes or any
training,,just started doing it one day seven years ago so there is MUCH I
don't know(like where is my variable? :) ).
Where is your Public variable?
Well, this is what I am using, but the Yes option and the No option produce
the same results,,,which is "Cancel".
[quoted text clipped - 13 lines]
 
R

ruralguy via AccessMonster.com

A variable is an object that you can reference and change whenever you want.
A Public Variable is defined outside of any procedure:

Option Compare Database
Option Explicit
Dim MyVariable As Integer
or
Public MyVariable As Integer

they both do the same thing since the default for this area of the module is
Public.

This will initialize to 0 because it is an integer. What code do you have
behind your icons that sets the RecordSource?

errr,,,,I don't have one? I am a true novice and have taught myself
everything I know -which isn't a whole bunch. Never took classes or any
training,,just started doing it one day seven years ago so there is MUCH I
don't know(like where is my variable? :) ).
Where is your Public variable?
[quoted text clipped - 3 lines]
 
R

rebecky via AccessMonster.com

This button brings up Open and Pending Positions. The queries are actually
name Query2111 and 21 I think but that gets confusing so I renamed them here.


Me.RecordSource = "SELECT * FROM HotPositions " _
& "WHERE [open_filled] like 'open' Or [open_filled] like 'pending'"


And this button brings up Parking Lot Employers

Me.RecordSource = "SELECT * FROM ParkingLotEmployers " _
& "WHERE [prospect] =true"


And there is a button for All Positions that uses
Me.RecordSource = "SELECT * FROM QUERY2111"

A variable is an object that you can reference and change whenever you want.
A Public Variable is defined outside of any procedure:

Option Compare Database
Option Explicit
Dim MyVariable As Integer
or
Public MyVariable As Integer

they both do the same thing since the default for this area of the module is
Public.

This will initialize to 0 because it is an integer. What code do you have
behind your icons that sets the RecordSource?
errr,,,,I don't have one? I am a true novice and have taught myself
everything I know -which isn't a whole bunch. Never took classes or any
[quoted text clipped - 6 lines]
 
R

ruralguy via AccessMonster.com

Added to in line assuming the Public Variable MyVariable:
This button brings up Open and Pending Positions. The queries are actually
name Query2111 and 21 I think but that gets confusing so I renamed them here.


Me.RecordSource = "SELECT * FROM HotPositions " _
& "WHERE [open_filled] like 'open' Or [open_filled] like 'pending'" MyVariable = 0

And this button brings up Parking Lot Employers

Me.RecordSource = "SELECT * FROM ParkingLotEmployers " _
& "WHERE [prospect] =true" MyVariable = 0

And there is a button for All Positions that uses
Me.RecordSource = "SELECT * FROM QUERY2111" MyVariable = -1

A variable is an object that you can reference and change whenever you want.
A Public Variable is defined outside of any procedure:
[quoted text clipped - 16 lines]
 
R

ruralguy via AccessMonster.com

Then your Printout code looks more like:

If MyVariable Then
If MsgBox("Do You want to Print the Entire Database?", vbYesNo, "TED
version
2.1") = vbYes Then
DoCmd.PrintOut
Else
Cancel = True
End If
Else
DoCmd.PrintOut
End If

Added to in line assuming the Public Variable MyVariable:
This button brings up Open and Pending Positions. The queries are actually
name Query2111 and 21 I think but that gets confusing so I renamed them here.


Me.RecordSource = "SELECT * FROM HotPositions " _
& "WHERE [open_filled] like 'open' Or [open_filled] like 'pending'"
MyVariable = 0
And this button brings up Parking Lot Employers

Me.RecordSource = "SELECT * FROM ParkingLotEmployers " _
& "WHERE [prospect] =true"
MyVariable = 0
And there is a button for All Positions that uses
Me.RecordSource = "SELECT * FROM QUERY2111"
MyVariable = -1
A variable is an object that you can reference and change whenever you want.
A Public Variable is defined outside of any procedure:
[quoted text clipped - 16 lines]
Thanks in advance for any help.....
rebecky
 

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