Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating a Generic Macro

Status
Not open for further replies.

Sandman007

Programmer
Jun 20, 2001
47
0
0
US
I want to be able to double click in any date field to set it to the current date. I can make a macro that does this, but I have to explicitly refer to the field on the form that I want to update. Therefore, if I have 50 such date fields (which I do), I would have to create 50 separate macros. I'm trying to figure out some sort of "Me" syntax so that I can call the same macro from whatever field I want. Is this possible?
 
I'm not sure what kind of magic you're looking for here, but why would you want to call a macro instead of simply assigning Date()to the control then and there? You still have to code the macro call behind every double-click event for every date field!

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
The reason I don't default it to Date() is that the user will be going into the form at different points in time to set certain fields based on things that have occurred. So they might want to set two or three of the dates to today's date and leave the rest as they are. The dates must remain open until the applicable event has occurred.
So while I will still have to call the macro from each of the fields it would be nice if I didn't have create separate code for each of them.
 

I want to be able to double click in any date field to set it to the current date.
Code:
Private Sub TheDateField_DblClick(Cancel As Integer)
    TheDateField = date()
End Sub

Just as easy as calling the macro and probably LESS coding. If you try to create a macro to do this, you'll have to pass in the name of the control/field you want updated.



Randy
 
I didn't say anything about defaulting to Date()! I said "why would you want to call a macro instead of simply assigning Date()to the control then and there" exactly what randy700 has suggested!

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 



Hi,

Take a look at
[tt]
ctr+;
ctr+:
[/tt]

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 

Show off! Old timers like myself are used to using keyboard shortcuts, but most of the new kids want to use the rodent! You wouldn't believe how many times I've been asked, "Why is there a letter underlined on all the buttons?"

God knows, it took me a long time to get used to using the mouse instead of shortcuts! The date one isn't half bad, but the <Ctrl> + <Shift> + <:> for time is a pain! And hardly anyone besides myself uses the double-click event anyway.

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top