Yahoo Answers is shutting down on May 4th, 2021 (Eastern Time) and beginning April 20th, 2021 (Eastern Time) the Yahoo Answers website will be in read-only mode. There will be no changes to other Yahoo properties or services, or your Yahoo account. You can find more information about the Yahoo Answers shutdown and how to download your data on this help page.

how to programme MS-Access Report with VB code?

What is the VB code to access report in MS-Access and its controls (e.g. textbox, labels etc.)?

4 Answers

Relevance
  • Anonymous
    2 decades ago
    Favorite Answer

    Do you mean VBA code ?

    I use XP2002. Regardless (not VBA), you will need the Access class library loaded. In coding environment right-click object browser toolbar button, select library references (I think), scroll down to the cluster of Microsoft DLL, select the appropriate object - Access 10, etc. Once that library is loaded you can code the access report object from your module. You'll need a connection object. This will require appropriate admin/owner passwords for the mdb file.

  • 2 decades ago

    A form is more dynamic than a report. In my opinion, a report is something static that can be sent to a printer.

    Having said that, there are events on an Access form. And code can be placed in there to do things like:

    onActivate, decide what the recordsource of the report should be. me.recordsource = .....

    It may be that you want a textbox to display a global value that you declared as a public variable in a module.

    Then me.mytextbox.value = myglobalvariable may occur during the onActivate event. Me. should force access to list all the text boxes, etc. available on the report that you are currently coding.

  • 2 decades ago

    Do you mean a FORM in MS-Access?

    If so, then usually give the control focus and then read or write the appropriate property.

    Examples:

    'to display HELLO in a text box named txt100

    Me.txt100.SetFocus

    Me.txt100.Text = "HELLO"

    'below is an example SUB to set the backcolor of a label

    'the label color may be expressed as a number

    Sub setBackColor(ctl As Label, lngColor As Long)

    Dim myColor As Long

    Dim myControl As Label

    myColor = lngColor

    Set myControl = ctl

    myControl.BackColor = myColor

    Set myControl = Nothing

    End Sub

    I hope that this helps!

  • Anonymous
    5 years ago

    yes

Still have questions? Get your answers by asking now.