Calendar Problem/First Field problem

Ron Wilson

Registered User.
Local time
Today, 16:19
Joined
Feb 12, 2008
Messages
11
Hi,

I have a couple of problems. Firstly, when I load a form, the first field (primary key) has a 0 in it. I would like to just have the field empty and have the tab order set to default on this field on load.

Secondly, I have a calendar on my form, which populates a text box:

Private Sub Calendar1_DateSelected(Code As Integer)

Text57.Text = e.Start.ToShortDateString()

End Sub

However, I need to click on a text field to see the text box being populated with the date. How can I have it so that as soon as I click on the date on the calendar, the textbox is populated? Thanks....
 
Go into the Design View for your underlying table, select the Primary Key field, move down to Default Value. This current has a zero in it. Hilight and delete the zero. Exit and save.

To have your field always the first with focus

Code:
Private Sub Form_Current()
  YourField.SetFocus
End Sub
To be honest, I have no idea what this line of code is supposed to do:

Text57.Text = e.Start.ToShortDateString()

especially the hilited part. For one thing, the .Text Property can only be used when the control in question has focus. At all other times the .Value Property should be used, and since the .Value Property is the default property for textboxes, instead of Text57.Value you can simply use Text57. The usual way to assign a calendar value would be

Code:
Private Sub Calendar1_AfterUpdate()
  Me.Text57 = Me.Calendar1
End Sub
 
thanks for your help
 

Users who are viewing this thread

Back
Top Bottom