setting default in control

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a form (frmMaintenance) with a checkbox on it. I want to be able to
change the default by looking at a table (tblSys) and setting the default
value by getting that value found in the table. The description field will
either contain =Yes or =No depending on what I am doing at the time.

Table structure:
TblName: tblSys
(f1) Comparison (f2) ReturnVal (f3)
Description
cur values: Username BobbyS =Yes

My understanding is that I can set the default value of the checkbox to
equal the value in the Description field. I have put the following in the
default value of the checkbox (name: chkIt):

=DLookup("[Description]", "tblSys", "[Comparison]"="""Username")

This doesn't seem to work. What am I doing wrong?

Also, can I create a variable = the dlookup above and then change the
Description field to =No or do I have to go about it another way?

Thank you.
 
not checked your problem but
=DLookup("[Description]", "tblSys", "[Comparison]"="""Username")

should be
=DLookup("[Description]", "tblSys", "[Comparison]=""" & CurrentUser() &
"""")

to make more sense - John

I'm not sure of which versions "CurrentUser()" applies to, check current
usage in help.
 
Setting the default value of a control sets the value which is entered in a
new record.
It has no effect on existing records.
If this isn't enough to answer your question, perhaps you can provide a bit
more explanation of how you intend to use this default value.

For your second question, too, it would be useful to understand more of what
you hope to accomplish by doing this.
 
Hope this explanation makes sense. I have a switchboard with a button that
allows the user to delete test/dummy records. When they click the button a
form (frmDelTests) opens with a warning and instructions as to what is going
to happen. When the user selects the button to delete the data, I want the
button's visible property on the switchboard form (frmMaintenance) set to No
so that from that point on, enen when the database is opened the next time,
the button does not appear. I created the table referred to previously to
store a username and then using the =Yes or =No in the table to set the value
of the checkbox. Then, on the switchboards on load event, check the value to
determine if the button was visible or not. I suppose it would be alright to
delete the button on the switchboard, but it looks like I would have the same
problem as setting the default value.

I can get the button's visible property to change while the form is open but
not permanently. As soon as the form is closed and reopened, the buttons
reappear.

I hope that what I am trying to do can be done. If so, I really need some
help.

Thanks

MacDermott said:
Setting the default value of a control sets the value which is entered in a
new record.
It has no effect on existing records.
If this isn't enough to answer your question, perhaps you can provide a bit
more explanation of how you intend to use this default value.

For your second question, too, it would be useful to understand more of what
you hope to accomplish by doing this.

BobbyS said:
I have a form (frmMaintenance) with a checkbox on it. I want to be able to
change the default by looking at a table (tblSys) and setting the default
value by getting that value found in the table. The description field will
either contain =Yes or =No depending on what I am doing at the time.

Table structure:
TblName: tblSys
(f1) Comparison (f2) ReturnVal (f3)
Description
cur values: Username BobbyS =Yes

My understanding is that I can set the default value of the checkbox to
equal the value in the Description field. I have put the following in the
default value of the checkbox (name: chkIt):

=DLookup("[Description]", "tblSys", "[Comparison]"="""Username")

This doesn't seem to work. What am I doing wrong?

Also, can I create a variable = the dlookup above and then change the
Description field to =No or do I have to go about it another way?

Thank you.
 
I think this could work fine - you just need to set the checkbox's actual
value, not its defaultvalue.

BobbyS said:
Hope this explanation makes sense. I have a switchboard with a button that
allows the user to delete test/dummy records. When they click the button a
form (frmDelTests) opens with a warning and instructions as to what is going
to happen. When the user selects the button to delete the data, I want the
button's visible property on the switchboard form (frmMaintenance) set to No
so that from that point on, enen when the database is opened the next time,
the button does not appear. I created the table referred to previously to
store a username and then using the =Yes or =No in the table to set the value
of the checkbox. Then, on the switchboards on load event, check the value to
determine if the button was visible or not. I suppose it would be alright to
delete the button on the switchboard, but it looks like I would have the same
problem as setting the default value.

I can get the button's visible property to change while the form is open but
not permanently. As soon as the form is closed and reopened, the buttons
reappear.

I hope that what I am trying to do can be done. If so, I really need some
help.

Thanks

MacDermott said:
Setting the default value of a control sets the value which is entered in a
new record.
It has no effect on existing records.
If this isn't enough to answer your question, perhaps you can provide a bit
more explanation of how you intend to use this default value.

For your second question, too, it would be useful to understand more of what
you hope to accomplish by doing this.

BobbyS said:
I have a form (frmMaintenance) with a checkbox on it. I want to be able to
change the default by looking at a table (tblSys) and setting the default
value by getting that value found in the table. The description field will
either contain =Yes or =No depending on what I am doing at the time.

Table structure:
TblName: tblSys
(f1) Comparison (f2) ReturnVal (f3)
Description
cur values: Username BobbyS =Yes

My understanding is that I can set the default value of the checkbox to
equal the value in the Description field. I have put the following in the
default value of the checkbox (name: chkIt):

=DLookup("[Description]", "tblSys", "[Comparison]"="""Username")

This doesn't seem to work. What am I doing wrong?

Also, can I create a variable = the dlookup above and then change the
Description field to =No or do I have to go about it another way?

Thank you.
 
Back
Top