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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Problem with Date Picker

Status
Not open for further replies.

tamus121

Technical User
Mar 19, 2007
38
GB
I have a form which when opened has two text boxes populated from the previous form, e.g

Code:
=[Forms]![CustomerRecords]![RegNo]
and
Code:
=DLookUp("FullName","LoginDetailsQuery")

The form has a few other text boxes for data entry by the user and a date picker.

If the user enters the date first the pre-populated text boxes go blank and and re-popualte if data is entered into another text box. I could work round this by disabling the date field until some data has been entered but there must be something wrong in my code but I don't know where to look. I could have been certain this wasn't happening before but only noticed it when reviewing test data and dicovered the blank fields for some of the records in the table

Any suggestions on what would cause this?
tamus
 
Since these are calculated controls certain form events will cause these to recalculate. Without seeing your code, my guess is that they start to recalculate which causes them to go blank, but they do not finish. You could try add DoEvents in the after update event of the datepicker. You can google doevents, but basically it gives control back to the application allowing cached events to finish.

However, you could avoid this by setting the values in code instead of using calculated control. That is not to say what you are doing is wrong, it is just another way. So in the form's load event.

me.somecontrol.value = [Forms]![CustomerRecords]![RegNo]
me.someothercontrol.value = DLookUp("FullName","LoginDetailsQuery")

you would have to remove the current control source of the calculated controls. If it goes blank now, then there has to be some additional code causing it.
 
How are ya tamus121 . . .

If the previous form is closed right after the opened form then [blue]MajP[/blue] is correct. Otherwise something else is causing the controls to go blank.

So ... does the previous form remain open?

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

See Ya! . . . . . .

Be sure to see faq219-2884 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
I change the Me.Visisble = False and store the name of the form in a Global variable and then change it back to True when I close Stplabels. I have five of these commands on "CustomerRecords" all operating in the same way and having the same problem.

Code:
Private Sub LabelCmd_Click()

On Error GoTo Err_LabelCmd_Click

    Dim stDocName As String

    stDocName = "StpLabels"
    Me.Visible = False
    OpenCloseFrmID = "CustomerRecords"
    DoCmd.OpenForm stDocName
        
Exit_LabelCmd_Click:
    Exit Sub

Err_LabelCmd_Click:
    MsgBox Err.Description
    Resume Exit_LabelCmd_Click

End Sub

The only thing I have done differently with this code from previously is add Option Explicit at the top of all my code. I have removed this from the code and tested again but still these go blank.

When the form opens if the user enters details into any of the available fields before entering the date this does not occur.

If the user enters the date first via the date picker the two fields go blank. If the user saves the data at this stage the RegNo. and the Fullnames are not saved - this is understandable as they are used to update two hidden text boxes bound to the table. If the date is entered manually into the text box the details in the two boxes disappears but returns quickly!

If the user enters more data after the date the values then return to the two boxes.

Not sure if this makes sense? Is there some sort of updating going on but with the date picker it doesn't refresh properly?
tamus
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top