Defaulting dates

J Carvell

Board Regular
Joined
Sep 20, 2005
Messages
55
I have set up a form that automatically defaults the date received to todays date.

I would like this to remain so if the form is accessed from the 'MainMenu' form I have created. However, if I access the form from a different form, I would like the received date to default to the same recevied date on that different form.

Is this possible?
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
It sounds to me like you're doing a simple ".Show" approach, e.g.
Code:
UserForm1.Show
This works fine but it does lack flexibility such as you require. Instead you can go down the object-oriented route. If this means nothing to you then essentially you can use UserForm1 as a kind of template and create new copies of it to play around with, e.g.
Code:
Dim frm1 as UserForm1
Set frm1 = New UserForm1
frm1.TextBox1.Value = "new value"
frm1.Show
This create a new copy of UserForm1 (which I've called frm1) and writes "new value" in TextBox1 on that form before showing it.

Using your form this way can clog up memory, so when you're finished it's a good idea to tidy up:
Code:
Set frm1 = Nothing
So what I'd consider doing is to write a macro that shows the required form using code like that above. Give the macro 1 parameter - the date you want to display - then write it in before showing the form.

Hope this is giving you some ideas to play with!
 
Upvote 0

Forum statistics

Threads
1,219,162
Messages
6,146,660
Members
450,706
Latest member
LGVBPP

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top