how to open a table only from a specific record?

  • Thread starter Richard Farrell
  • Start date
R

Richard Farrell

I have a data base of contractors and vendors. There are
several hundred contractors and each contractor has many
contacts. this works just great. now the problem I have
some special contractors that I have lot of data and
account information such as dates weights ticket number
etc. I have all this information in a table and a form.
works great What I want is to have a icon or command
button that can open this table BUT it wil only be
visible or activated when you are looking (that is open
to that specific record)at a specific contractor. This
button does not need to be avaiable in 99% of my
contractor entries.

Thanks in advance
(e-mail address removed)
 
T

Tom Wickerath

Hi Richard,

Does the recordset, upon which your form is based, include a field that can be used to determine
whether or not to display your command button? This could be a simple Yes/No field, or something
more complex. Lets say the name of the command button is "cmdOpenTable" and that you have a
Yes/No field in the recordset named blnTableVisible (bln for boolean). Also, the name of the
table that you want to open is "tblContractors". You could then insert the following code into
the form's On_Current event procedure:

Private Sub Form_Current()
On Error GoTo ProcError

Me.cmdOpenTable.Visible = Me.blnDiscontinued


ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in Form_Current event procedure..."
Resume ExitProc
End Sub



The code for the On_Click event procedure for the command button would be:

Private Sub cmdOpenTable_Click()
On Error GoTo ProcError

DoCmd.OpenTable "tblContractors"

ExitProc:
Exit Sub
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, _
vbCritical, "Error in cmdOpenTable_Click event procedure..."
Resume ExitProc
End Sub

Tom
__________________________________________


I have a data base of contractors and vendors. There are
several hundred contractors and each contractor has many
contacts. this works just great. now the problem I have
some special contractors that I have lot of data and
account information such as dates weights ticket number
etc. I have all this information in a table and a form.
works great What I want is to have a icon or command
button that can open this table BUT it wil only be
visible or activated when you are looking (that is open
to that specific record) at a specific contractor. This
button does not need to be available in 99% of my
contractor entries.

Thanks in advance
(e-mail address removed)
 

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