passing date value from ListBox to TxtBox

uberDave

New member
Local time
Today, 06:29
Joined
Oct 5, 2005
Messages
7
Hi i'm making an HR app to keep track of Staff Sickness, Annual Leave and Personal info. I'm currently trying to do some calculations using short date values, to do this i'm reading the dates from a table into a listBox and then transfering the value into a temporary txtBox do the calcualtion display the result and then save the result back to my table. The problem i'm having is passing the value from the listBox into a txtBox. I just can't get it to work and i've tried everything I can think of.


'This just doesn'twork

txtDateTemp2.Value = listLastDaySick.Column(0)



Iknow this is a really simple problem i'm just stumped. Any help would be greatly appreciated.

P.S. Is what i'm trying to do just plain stupi is there a much simpler way to work with dates in tables?
 
hmmm

ok i've been playing with it for a bit and i've found that if I use :
txtDateTemp2.Value = Me!listLastDaySick.Column(0)

and click the listbox itwill display the value in the int the txtBox, how can I do this with out having to click the listbox?
 
I don't know about others but I'm confused of your description. You have one listbox and one textbox. Will the listbox have more than "1" date? If it has "only" 1 date then you don't need it. One textbox should be enough. If it has more than "1" date, the date that you want calculated will need to be selected in order to pass it to the textbox by clicking on it (assuming your passing statement is in the listbox's afterupdate sub).

Now to make a date auto-selected when the form is loaded, use this:
Me!listLastDaySick.Selected(number) = True
where "number" is the order of your date. Using Me!listLastDaySick.ListCount will give you the number of records listed in the listbox, starting from 0.

Therefore, if you want the first record in the listbox to be auto-selected then the statement above would be:
Me!listLastDaySick.Selected(0) = True
For the last record to be selected: Me!listLastDaySick.Selected(listLastDaySick.ListCount - 1) = True

Hope this will help.
 
thanks

Thanks Supercharge, sorry if my question was hard to understand, looking back at it now I see what you mean. I'm just being a bit of a n00b at the mo, haven't done any database work for a few years, the
' Me!listLastDaySick.Selected(number) = True ' comment wasn't what I was looking for but it jogged my mind a bit and made me realise I was going about this all wrong, re-coded and changed my forms a bit and all is working now. Thanks for your help! :cool:
 

Users who are viewing this thread

Back
Top Bottom