Passing date ranges from combo box to txt (1 Viewer)

yeasir01

Registered User.
Local time
Yesterday, 19:26
Joined
Mar 26, 2018
Messages
67
Hello,

I'm trying to pass a VBA snippet that stored in a table into two text box from a single combo box. The VBA code I'm using is as followed in the after update of the combo box. The problem I'm having is instead of setting the value, it is passing the value as a string. for example "Date()" for today instead of 5/14/2018. Any Ideas?

Code:
me.txt_start = cmb_daterange.column(2)
me.txt_end = cmb_daterange.comun(3)

The table stores the following
ID, Description, Start Code, End Code
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 10:26
Joined
May 7, 2009
Messages
19,249
Should return the actual date value.
Is string "date()" is being returned you can use eval() function to return the date:

If instr(me.mb_daterange.column(2) & "", "Date()") > 0 then
me.txt_start = Eval(cmb_daterange.column(2))
Else
...
 

yeasir01

Registered User.
Local time
Yesterday, 19:26
Joined
Mar 26, 2018
Messages
67
Should return the actual date value.
Is string "date()" is being returned you can use eval() function to return the date:

If instr(me.mb_daterange.column(2) & "", "Date()") > 0 then
me.txt_start = Eval(cmb_daterange.column(2))
Else
...

Thank You! That did the trick
 

yeasir01

Registered User.
Local time
Yesterday, 19:26
Joined
Mar 26, 2018
Messages
67
Should return the actual date value.
Is string "date()" is being returned you can use eval() function to return the date:

If instr(me.mb_daterange.column(2) & "", "Date()") > 0 then
me.txt_start = Eval(cmb_daterange.column(2))
Else
...

Sorry jumped the gun on that one it doesn't seem to work for codes such as the one below.

Last Month(start): DateSerial(Year(Date), Month(Date) - 1, 1)
Last Month (end): DateSerial(Year(Date), Month(Date), 1) - 1
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 22:26
Joined
Feb 19, 2002
Messages
43,626
If you want reusable code, create procedures or functions in a standard module and call them.
 

Users who are viewing this thread

Top Bottom