Solved

Date Picker problem

Posted on 2012-03-20
17
412 Views
Last Modified: 2012-03-26
This is only a little gripe, but the people using my application would like it fixed if possible....

A data entry form has a Text Box in which a date is entered. This is the last control on the form before they click a command button in order to save the record.

Most users will use the date picker in order to select the date. But when they choose a date, the date appears in the text box, but the cursor is still flashing in there indicating the value has not been commited into the box.

The users will normally click the date picker to select a date, then click the Save Button to save the record. What they are finding is that they have to click the Save Button twice. The first click commits the date which has been selected by the date picker, then the second click fires my OnClick event handler for the Save Button.

Is there any way that I can force the date picker to commit the value into the text box so that is not sat there waiting to be entered?
0
Comment
Question by:TownTalk
  • 8
  • 7
  • 2
17 Comments
 
LVL 77

Expert Comment

by:peter57r
ID: 37743045
I think you should be able to use the textbox's Change event procedure to set the focus to the button.
0
 

Author Comment

by:TownTalk
ID: 37743082
I could very easily do that if everyone used the data picker, but sometimes a user will type a date manually. The Change event cannot test the contents of a control while it is being edited. So I have no means of knowing when the control contains a valid date.
0
 
LVL 77

Accepted Solution

by:
peter57r earned 500 total points
ID: 37743133
If isdate(me!textboxname.text) then me.buttonname.setfocus
0
 

Author Comment

by:TownTalk
ID: 37743198
That's interesting.... In the Change event I had already tried:

If isdate(me!textboxname) then me.buttonname.setfocus

I tried putting .text on the end of the control name:

If isdate(me!textboxname.text) then me.buttonname.setfocus

 and now it gives me the error:

You can't reference a property or method for a control unless the control has the focus.

This is an unbound form by the way. I dont know if that makes any difference.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37743310
1. What the need for a "Save" button anyway..?
In Access the records are saved automatically...

2. What code are you using for this "Save"

3. Just for fun, I tried your setup, and it worked fine...
(No need to click save twice...)
0
 
LVL 77

Expert Comment

by:peter57r
ID: 37743329
I wouldn't expect using an unbound control to make any difference.
The message doesn't really make any sense if you are in the change event for the textbox containing the date - the textbox must have the focus in that situation.
0
 

Author Comment

by:TownTalk
ID: 37743374
@boag200 No the records are not saved automatically. This is an unbound form. I have some code which takes the form data and updates the SQL Server.

@Peter57r: Yes the Textbox has the focus at this time. So it would appear to be a misreported error. But can I ask please, are you under the impression that the change event should be able so see the contents of a text box while it is being edited? I thought that only the BeforeUpdate event could do this.
0
 
LVL 77

Expert Comment

by:peter57r
ID: 37743410
The change event sees every character entered, provided you use the .text property.

I have now built a simple test form here and I can't re-create your problem at all.  Are you sure you don't have other code running that is affecting the process?
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Author Comment

by:TownTalk
ID: 37743481
I tried this simple code:

Private Sub DateRequired_Change()
   
    Debug.Print Me![DateRequired]
       
End Sub

each time I press a key, the full previous value of the field is written to the immediate window. The new value I am typing is not displayed at all. So I think maybe the problem is caused by it being an unbound form
0
 
LVL 77

Expert Comment

by:peter57r
ID: 37743566
You are not using the .text property.
0
 

Author Comment

by:TownTalk
ID: 37743660
Yes you are correct, but as we know, I get an error if I use the .text property

I tried this:

Private Sub DateRequired_Change()
                   
    Me![DateRequired].SetFocus
    If IsDate(Me![DateRequired].Text) Then Me![SaveButton].SetFocus
       
End Sub

But it still gives me error 2185
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37743716
<No the records are not saved automatically. This is an unbound form. I have some code which takes the form data and updates the SQL Server.>
Oh, OK....
0
 
LVL 77

Expert Comment

by:peter57r
ID: 37743717
You have said that this  is an unbound control, yes?  Then I can't see how this error arises.

If it were bound then you must distinguish between the textbox name ans the controlsource name by changing the name of the textbox to say, txtDateRequired (and that will affect the event procedure name, of course)
0
 

Author Comment

by:TownTalk
ID: 37744443
No it's a completely unbound form. Nothing is bound. I have a routine which populates the controls with data from the Sql Server, and another routine which writes any changed data back afterwards.

Sorry for the delay replying. It's evening here now, so I am on my home pc
0
 

Author Comment

by:TownTalk
ID: 37765125
This question seems to have dried up. I dont have a solution yet. Anyone got any other suggestion?
0
 
LVL 77

Expert Comment

by:peter57r
ID: 37765185
I think you will have to post a sample file which shows the problem.

As I said earlier i can't reproduce the problem.  The .text property works fine for me in a Change event.
0
 

Author Comment

by:TownTalk
ID: 37766006
@Peter: I created a sample database with just a Text Box and a Save Button. It didn't have the problem. So I imported my Sales Order form from the main application. It also worked perfectly.

So I went back to my main application and Decompiled, Repaired and compacted it, and the problem went away. I hate it when that happens

So now your suggestion for the Change event works. Thank you for your help.

Ian
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Overview: This article:       (a) explains one principle method to cross-reference invoice items in Quickbooks®       (b) explores the reasons one might need to cross-reference invoice items       (c) provides a sample process for creating a M…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
Familiarize people with the process of utilizing SQL Server stored procedures from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Micr…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now