Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Empty Text Boxes Until Cursor Is In Them

Status
Not open for further replies.

xmeb

Technical User
Jun 5, 2013
89
0
0
I have several forms that use DCount, DLookup, DMin, and DMax. When I open the form the "D" text boxes are empty until I put the cursor in it and the correct value then appears. If I set the tab order to "0" on a particular "D" text box and open the form the value is displayed but that is no help when a form has several "D" text boxes. Is there a solution to this? Thanks.
 
How are ya xmeb . . .

Where do the domain functions reside? ControlSource, Event triggered VBA? I could do the same thing using the [blue]OnGotFocus[/blue] event.

[blue]Your Thoughts . . .[/blue]

See Ya . . .

Be sure to see FAQ219-2884 Worthy Reading! [thumbsup2]
Also FAQ181-2886 Worthy Reading! [thumbsup2]
 
xmeb,

It could be that you need to put the D functions (or use a different method altogether if you have a large database - D functions tend to run slowly - the bigger the data source, the slower it'll run) in an event location. It sounds to me like you have them set to the Default Value, and that value isn't updating at the right time, b/c you don't have the values required to calculate the value set when the form loads.

Post back and let us know your progress.

"But thanks be to God, which giveth us the victory through our Lord Jesus Christ." 1 Corinthians 15:57
 
Problem still exists. Any ideas?
 
You haven't provided the exact expressions you are using or if they depend on the data in the record source of the form.

I would recommend getting rid of the D functions and using code to place values in the controls.

Duane
Hook'D on Access
MS Access MVP
 
Yeah, I agree. These "D" functions have been nothing but trouble. However, I have never used code for something like this. Below are some of them. Could you get me started? Thanks.

Code:
=DCount("ID","DataTable")
=DMin("[RoadNumber]","ResidencesTable","[RoadName] Like '*" & [ResidencesFormRoadNameTextBox] & "*'")
=DCount("*","ResidencesTable","[RoadName] Like ""*" & [ResidencesFormRoadNameTextBox] & "*""")
 
Allen Browne has an alternative to DLookup() at this page.

You can also use faq701-4233 to return a single or multiple values.

Code:
=Concatenate("SELECT Count(*) FROM DataTable")
=Concatenate("SELECT Min(RoadNumber) FROM ResidencesTable WHERE RoadName Like '*" & [ResidencesFormRoadNameTextBox] & "*'")

You should also make sure fields used in comparisons are indexed.

Duane
Hook'D on Access
MS Access MVP
 
I do not see any issue with your domain aggregate functions. Allen Browne's post was prior to Access 2007, before they greatly improved the performance of domain aggregates. Although there are some other fixes. Also the one's you present seem pretty basic. If they are not showing until you enter that field, it sounds to me as they are not calculating.
To test this hit F9 and see if they appear. If so add a Me.recalc method in the forms current event. This will recalculate all controls.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top