[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5171
  • Last Modified:

MS ACCESS Can I change the button?



I used the form wizzard to build my form.  I have eddited to make some changes in placement etc to my liking.

I dont like the default buttons it usess to go though records and to add a new record.  Is there a way to change these buttons?

If so how?
0
mrchaos101
Asked:
mrchaos101
2 Solutions
 
Alan WarrenCommented:
Sure!
Create your own buttons for back and forward

' Command button called btnPrevious OnClick Event Procedure

Private Sub btnPrevious_Click()
  Dim gmsgText as String

On Error GoTo ReportError

  DoCmd.GoToRecord , , acPrevious

ExitProcedure:
  On Error Resume Next
  DoCmd.Hourglass False
  DoCmd.SetWarnings True
  Exit Sub

ReportError:
 
  Select Case Err.Number
    Case Is = 2105
      ' You can't go to the specified record.
      ' Do nothing
    Case Else
      gmsgText = "Error in " & Me.Name & ".btnPrevious_Click()" _
        & vbCr & "Error number " & CStr(Err.Number) _
        & " was generated by " & Err.Source _
        & vbCr & Err.Description
      MsgBox gmsgText, vbExclamation + vbMsgBoxHelpButton, "Error", Err.HelpFile, Err.HelpContext
  End Select
  Resume ExitProcedure


End Sub


' Command button called btnNext OnClick Event Procedure

Private Sub btnNext_Click()
  Dim gmsgText as String

On Error GoTo ReportError

  DoCmd.GoToRecord , , acNext

ExitProcedure:
  On Error Resume Next
  DoCmd.Hourglass False
  DoCmd.SetWarnings True
  Exit Sub

ReportError:
 
  Select Case Err.Number
    Case Is = 2105
      ' You can't go to the specified record.
      ' Do nothing
    Case Else
      gmsgText = "Error in " & Me.Name & ".btnNext_Click()" _
        & vbCr & "Error number " & CStr(Err.Number) _
        & " was generated by " & Err.Source _
        & vbCr & Err.Description
      MsgBox gmsgText, vbExclamation + vbMsgBoxHelpButton, "Error", Err.HelpFile, Err.HelpContext
  End Select
  Resume ExitProcedure

End Sub

You can do similar for last and  first and New

DoCmd.GoToRecord , , acLast
DoCmd.GoToRecord , , acFirst
DoCmd.GoToRecord , , acNewRec



Take care....


Alan

0
 
billmercerCommented:
If you want to change the appearance of a button, you can do that from the button's Format properties while in Design mode. Right click on the button and choose Properties. Look at the Format tab. You can change the text formatting, color, style, etc. You can also choose one of a number of built-in pictures for the button, or pick your own custom .BMP image.


0
 
mrchaos101Author Commented:
billmercer

that is kind of what im looking for... but when I use the BUILD FORM wizzard... it doesn't seem to put the button controlls on the form.

I has the labels and txt boxes etc...  I have changed the font size color etc... but no buttons

It doesn't seem to ADD the buttons to the form until you actualy run the from.
0
NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

 
billmercerCommented:
Ah, you're referring to the small set of buttons on the bottom of the screen. Those are actually a default set of buttons that can be added to any form. You can't really customize them directly. Instead you need to create your own buttons that do the same things, then arrange them and format them as you desire.

In design mode, click the Command Button icon in the toolbox, then click where you want the button to appear in your form. You'll be prompted to choose what the button will do. Choose Record Navigation, Go to First Record. Repeat the process, adding buttons that go to previous and next record, delete the current record, and so on. You can then customize and rearrange these buttons however you want.
Note that the default set of small buttons still shows up when you're entering data. To make it go away, go to the properties for the form and set "Record Selectors" to No. Now only your own buttons will appear.
0
 
billmercerCommented:
By the way, AlanWarren's suggestion shows how you can use programming in Visual Basic for Applications (VBA) to customize how a button behaves.
If you've never used VBA before it may seem intimidating, but it is really not as hard as it looks, and if you plan to do a lot of work in Access, it's VERY worthwhile to learn. Lots of things that are very difficult or impossible to do with a wizard-generated form are easy with VBA.

0
 
mrchaos101Author Commented:
Ok That is about what I was looking for... one probelm


I put  my buttons on.... and wanted to move them to th HEADER section...it would not let me.  So I cut and pasted the buttons up there.

It didn't work.  I figured I could not do it that way.  So I deleted the buttons.

I put a new button back where I orginaly started but NOW it doesn't aske me what I want to do.  How do I turn that back on?
0
 
mrchaos101Author Commented:
doh ok I see the command wizzard button it needed to be yellow lol

Got it fixed.


OK the guy the VBA code was the answer.... I do know VB so it was easy to under stand...

The other guy with the  Wizzard was more along the lines of what I was looking for.

Im gonna do a split on the points on this one.

Thanks all.

ALSO as Im still eaching my self ACCESS I will have more therads please keep looking and helping

Thanks
0
 
mrchaos101Author Commented:
alan  

I had another fast question here...

in vb we used a name deal like  cmdSomething for a comand button and txtTextBox for text boxes...


I am seeing a lot of the same controlles and code here.... is it safe to asume I should be using the same way to name controlls?
0
 
billmercerCommented:
If someone besides yourself may have to work on it in the future, then you definitely should. Even if you're the only user, it's probably a good idea, it will make it easier to figure out what your code is doing six months later when you've forgotten what that module does... :)
.


0
 
streetskaterCommented:
MS Access has it's own subset* of VisualBasic which makes rapid prototyping pretty easy and very fast.  **I call it a subset because even though it has some unique features geared specifically for Access, it doesn't have everything that full blow VisualBasic has.  

Psstt.  Over here.
I sometime use Access with VisualBasic to do proof of concepts before gearing up with Oracle-Powerbuilder or SQL Server.....Let's just keep it between ourselves though.

As you get your footing customizing Access I would definitely spend some time building interfaces to your database with VisualBasic proper--and then maybe VisualC++.  You'll have A Lot more flexibility in your presentation layer.  It will also teach you fundamental about how to remotely access your database engine --as in through a intra or internet interface,

I know that doesn't directly answer your question but I gotta spend some time here building points so I can ask my own lame questions....:-)
0
 
simply_juniorCommented:
You can create command buttons in MS Access....try to visit help file plz,,,,
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now