Command Buttons

cross5900

Blarg!
Local time
Today, 16:03
Joined
Mar 24, 2006
Messages
92
I am a newbie at Access and I am currently learning it for my job...I have a database going and I am wanting to do two things and I can not figure it out for the life of me.

Little background, the database I made is a continuous form. I am wanting a command button that when pushed will put it in data entry mode, and when pressed again will put back in a 'view all' state. I know it is a simple If Then, but I don't know VBA very well =\

Other thing, is I wanting to be able have button that when pressed will output to an excel sheet, right now I have it when it is pressed it asks me what kind of format I want outputted, and I want it automated to just go straight to excel.

Any help would be appreciated, thanks.
 
Welcome

Welcome to the forums!

I'll tackle the first of your inquiries. Place a button in the Form Header. Name it "cmdDataEntryMode" with a caption of "Data Entry Mode". Then attach this code to it's OnClick event:

Code:
Private Sub cmdDataEntryMode_Click()
On Error GoTo Err_cmdDataEntryMode_Click

  Me.DataEntry = Not Me.DataEntry
  If Me.DataEntry Then
    cmdDataEntryMode.Caption = "See All Records"
  Else
    cmdDataEntryMode.Caption = "Data Entry Mode"
  End If

Exit_cmdDataEntryMode_Click:
    Exit Sub

Err_cmdDataEntryMode_Click:
    MsgBox Err.Description
    Resume Exit_cmdDataEntryMode_Click
    
End Sub

Most of the code is just error handling. But the meat of the routine demonstrates some clever techniques.

Hope this helps,
Jeff
 
cross5900 said:
Other thing, is I wanting to be able have button that when pressed will output to an excel sheet, right now I have it when it is pressed it asks me what kind of format I want outputted, and I want it automated to just go straight to excel.
Check out the Access help files for the TransferSpreadsheet method.
 
Thanks guys, I will give this all a shot on Monday. Appreciate the responses and I am glad I found this place.
 

Users who are viewing this thread

Back
Top Bottom