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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable a command button

Status
Not open for further replies.

Khawer

Programmer
Sep 13, 2004
23
CA
Hello,

I'm not sure if this is possible, but here it goes. I have a switchboard with a "Print" button that prints info for today stored in the table. Is there a way to control the usage of this button so that it can be run only once in a day. If a user clicks, it prints the info and then disables the button till the next day. Once they open the database the next day the button is enabled again. If someone knows of a solution and can guide me in the right direction that be great. Thanks
 
To a table, you can write the verdict.
For example, your table could have just a date field.
Whenever button is clicked, you insert a record to
the table, with Now().

So on Switchboard_Load()
Dim varToday As Date
varToday = DLookUp("txtDate","tblEnablePrint", _
"txtDate =#" & Date & "#")

Me.cmdPrint.Enabled = IsNull(varToday)

End Sub
________________________________________________

cmdPrint_Click()
Dim SQL As string

Docmd.OpenReport "rptInfoToday",,acViewNormal....

SQL = "INSERT INTO tblEnablePrint(txtDate) " & _
"VALUES(#" & Date & "#)"
CurrentProject.Connection.Execute SQL,,129
 
Zion7,

Thanks, that worked. I'm actually trying to add another button "Save" with the same criteria and it gives me "Invalid use of null". I've got a table with 2 date fields "PDate" and "SDate" the table "PSDateCheck". What I did was:

--------------------------------------------
1.Dim varToday As Date
2.Dim varToday2 As Date
3.
4.varToday = DLookup("PDate", "PSDateCheck", _
5. "PDate =#" & Date & "#")
6.
7.Me.Option5.Enabled = IsNull(varToday)
8.
9.varToday2 = DLookup("SDate", "PSDateCheck", _
10. "SDate =#" & Date & "#")
11.
12.
13.Me.Option6.Enabled = IsNull(varToday2)

--------------------------------------------

It works good with the first button Option5, but it gives me the error on line# 9 with "Invalid use of null". Is there some fix for this? Thanks
 
I used a variant data type, because it allows nulls.

.Dim varToday As Variant
2.Dim varToday2 As Variant
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top