By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,269 Members | 1,507 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,269 IT Pros & Developers. It's quick & easy.

Suggestion for default value property setting on page 2 of tab control

P: n/a
MLH
I have a form named frmVehicleEntryForm. It has a 3-tab tab control.
On the 2nd tab page, there's a textbox named VehicleLocationName
whose default value setting is

=DLookUp("[TowCompany]","tblAdmin","[TowCoID]=Forms!frmVehicleEntryForm!TowCoDropDownBox")

The criteria of the DLookUp points to a control on tab page 1. If,
after choosing a company in TowCoDropDownBox, I click tab page 2,
I was hoping to see something like "XYZ Company" in the textbox named
VehicleLocationName. But I don't.

Oddly, if I change VehicleLocationName.DefaultValue property to
=DLookUp("[TowCompany]","tblAdmin")
I get what I want. A company shows up. Of course, its the first
company in the table. And most of the time, that's wrong - I have
35 different companies in that table.

The key seems to be the dlookup criteria. If there is no criteria,
Access looks up the value and puts it in the field. This is a data
entry form. Perhaps something I type into a control really isn't there
- at least not in the way Access wants it to be there when attempting
to READ the contents. Form properties AllowEdits, AllowDeletions,
AllowAdditions and DataEntry are all Yes.

Can I revise my criteria in the DLookUp to overcome my problem? Or,
should I not be trying to read what's in the field at all?
Jun 7 '06 #1
Share this Question
Share on Google+
6 Replies


P: n/a
If you can get the two values together in a query,. use the query as
the rowsource (or controlsource, can't remember!) of the your combobox.
Set the textbox to be unbound and point it to Me.MyCombobox(1) or
whatever column you want that youre hiding in your combobox. Problem
solved. No code required.

Jun 7 '06 #2

P: n/a
MLH
On 7 Jun 2006 09:37:10 -0700, pi********@hotmail.com wrote:
If you can get the two values together in a query,. use the query as
the rowsource (or controlsource, can't remember!) of the your combobox.
Set the textbox to be unbound and point it to Me.MyCombobox(1) or
whatever column you want that youre hiding in your combobox. Problem
solved. No code required.


Yes, I could do that. One way to do it would be to define a global
variable (gvSomeVar AS Variant) and write a global module to reference
and return the value of gvSomeVar. So there's a solution. Great.

I would still like to get to the bottom of why, on a form like that
I've described, I can set the DefaultValue of a textbox to
=DLookUp("[TowCompany]","tblAdmin","[TowCoID]=21")
==> and it works. But if I set it to
=DLookUp("[TowCompany]","tblAdmin","[TowCoID]=Forms!frmVehicleEntryForm!TowCoDropDownBox")
==> it doesn't work. And if I set it to
=DLookUp("[TowCompany]","tblAdmin")
==> it works.
Jun 7 '06 #3

P: n/a

On 7-Jun-2006, MLH <CR**@NorthState.net> wrote:

=DLookUp("[TowCompany]","tblAdmin","[TowCoID]=Forms!frmVehicleEntryForm!TowCoDropDownBox")

Try this:

=DLookUp("[TowCompany]","tblAdmin","[TowCoID]=" &
Forms!frmVehicleEntryForm!TowCoDropDownBox)

Note the difference in the Where parameter
Jun 7 '06 #4

P: n/a
MLH
On Wed, 07 Jun 2006 19:41:39 GMT, "Rick Wannall"
<wa*****@notadomain.de> wrote:

On 7-Jun-2006, MLH <CR**@NorthState.net> wrote:

=DLookUp("[TowCompany]","tblAdmin","[TowCoID]=Forms!frmVehicleEntryForm!TowCoDropDownBox")

Try this:

=DLookUp("[TowCompany]","tblAdmin","[TowCoID]=" &
Forms!frmVehicleEntryForm!TowCoDropDownBox)

Note the difference in the Where parameter


Well, I crossed my fingers and closed my eyes. Still didn't
work. My first syntax has no problem displaying the correct
TowCo name when run in the immediate window. Your syntax
works too, of course. In the data-entry form, however, nothing
seems to work that provides a reference criteria to the dlookup fn.
Jun 8 '06 #5

P: n/a
MLH
No such luck. I give up on trying to plug in a DefaultValue
property setting that works. Dunno why it doesn't work -
but I do know that it doesn't.

Using the following line in TowCoDropDownBox's AfterUpdate code
works just fine:

Me!VehicleLocationName=DLookup("[TowCompany]","tblAdmin","[TowCoID]=Forms!frmVehicleEntryForm!TowCoDropDownBox")

The only explanation I can come up with as to why putting essentially
the same instruction in the target textbox's DefaultValue property
setting MIGHT not work is because of the form being a data entry
form. But even if that is the controlling factor, I have no clue why.
Jun 8 '06 #6

P: n/a
Are you certain that there's a row selected in the combobox? If there's
not, then there's nothing to compare to, and that will return a NULL value
to the DLookup.
Jun 8 '06 #7

This discussion thread is closed

Replies have been disabled for this discussion.