Re: Command Button VB Coding
- From: "Ed Robichaud" <edrobichaud@xxxxxxx>
- Date: Tue, 12 Sep 2006 09:43:34 -0400
Sue-
An example: you would use the OnClick event of your "Add New Record" button
to reset the properties of those controls that you changed with your "Edit
Record" button. Something like:
DoCmd.GoToRecord , , A_NEWREC
'grey out the "Edit Record" button
Me!btnEditRecord.Enabled = False
'hide the "deletedate" textbox
Me!deletedate.Visible = False
'etc.
-Ed
"Sue Wilkes" <SueWilkes@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:8578EFE4-B731-412E-9B75-35BF7004CD7C@xxxxxxxxxxxxxxxx
Thank you Ed for your assistance but please forgive this newbie for asking
a
silly question; If I change the visible and enabled properties of the
reasonsforedit control to True/False on what event do I code the addnewrec
command button to active those properties and what would the code be. Many
thanks
"Ed Robichaud" wrote:
You can set your controls' Visible or Enabled properties to True/False
depending on which cmdbutton is used. Similarly, you could check the
values
of ReasonforEdit and DeleteDate in the control source of your reports'
title. Make your report title an unbound text field and set its control
source to something like:
=IIF(Isnull(Forms!myForm!ReasonforEdit) AND
Isnull(Forms!myForm!DeleteDate) "Entry Report",.....etc.
BTW, you should probably move the hyperlink1,2,3 fields to a related
table.
-Ed
"Sue Wilkes" <SueWilkes@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:E7A353D4-697C-41A3-9A96-AC47BF69252E@xxxxxxxxxxxxxxxx
I have a form linked to a table. I have designed the form to accept
entries,
edits and deletions. I have several questions in relation to command
buttons. Table fields are:
IDNo - Autonumber - primary key
RegisterNumber - Text - uses Me.NewRecord to create new number -
primary
key
DeptCode - Text - Table lookup using combo box
Designation - Text - Table lookup using combo box
DateSent - Date - =Date()
SentTo - Text
CompanyName(s) - Text
CopiedTo - Text
Subject - Text
Hyperlink1 - Hyperlink
Hyperlink2 - Hyperlink
Hyperlink3 - Hyperlink
UserName - Text - Captures user name using =fOSUserName()
UpdateLog - Text - Display audit log information if available
Reason(s)forEdit - Text
DeleteDate - Date - =Date()
DeptReqDel - Text - Table lookup using combo box
ReasonforDel - Text
PersonReqDel - Text - Captures user name using =fOSUserName()
Q1. I have three buttons; add new record, edit record, delete record.
I
would like to place VB code behind these buttons to grey out certain
fields
and NOT allow data entry/change depending on which button is selected
e.g.
if
add new record is selected I would like the control fields
'reasonsforedit',
reasonfordel, deletedate, deptreqdel, personreqdel etc..to be greyed
out
and
disabled.
Q2. I would also like to be able to validate fields with VB Code
dependent
on whether it is entry, edit or delete to ensure that all data required
has
been entered.
Q3. I have also have a print button to print the current recordset,
using
the code provided by Allan Browne. How can I code to print the correct
report 'entry report' or 'edit report' or 'delete report'?
For information I am also using the audit log created by Alan Browne.
I would appreciate it if anyone could please help me as I understand
very
little VB coding. I have tried using conditional formatting but could
not
get the box to grey out.
.
- References:
- Re: Command Button VB Coding
- From: Ed Robichaud
- Re: Command Button VB Coding
- From: Sue Wilkes
- Re: Command Button VB Coding
- Prev by Date: Re: Can I make Linked Table Read-Only
- Next by Date: Re: Can I make Linked Table Read-Only
- Previous by thread: Re: Command Button VB Coding
- Next by thread: Re: Access 2003: Viewing Table
- Index(es):