Question Converting Macro to VBA

tuisb3

Registered User.
Local time
Today, 14:10
Joined
Aug 1, 2013
Messages
14
Hi,

I am wondering if on the form properties I can have code and a macro at the same time on the oncurrent property?

I have some code for the current sheet i need to keep as is, but i also want a macro to run, There may be a better way of doing it through code but I am a newb when it comes to coding and i only know how to do it in a macro.

I have a macro that sets the back colour of the form if a property is ticked / true. The macro looks like this below. If anyone can tell me what the code would be for it instead or whether there is a way to have the macro and code running for the same property that would be great!

If [Top 20 Site]=True
Set Property
Control name Detail
Property BackColor
Value #FFD700
Else
If [Top 20 Site]=False
Set Property
Control name Detail
Property BackColor
Value #FFFFFF
End If

If someone can give me the code to do the same thing that would be great..

Also

Another question I have is... When the form is filtered the sizeable window option doesnt work. On the form i have the following properties set...

Auto Centre YES
Auto Resize YES
Fit to Screen YES
Border Style Sizeable

When on a blank new form it seems i can stretch the window and on windows 7 drag it to the top of the screen and it sizes fullscreen for me, if the form is however on a certain record or filtered the window stays static and wont stretch and you cannot freely resize or stretch it. However the properties always look the same when in design mode.

Any help for a newb would be much appreciated!!!

Many thanks

Steve
 
If you have 2007 or later Access can convert it automatically, however the code that it produces does not always work, therefore you may have to modify it slightly
 
Hi,

Sorry I should have said but I have tried this already and it errors when trying to convert it :(

Thanks

Steve
 
have you tried a simple If statement

Code:
If Top20Site = True then
me.ControlName.backcolor = vbWhite
Else
me.ControlName.backcolor = vbYellow
end if

on a side note. keep spaces out of your object and control names
 
OK thanks RODMC...

I have tried...

Private Sub Form_Current()
If Top20Site = True Then
Me.Detail.BackColor = vbYeloow
Else
Me.Detail.BackColor = vbWhite
End If
End Sub

However it doesnt like Form_Current() and gives me an error Ambiguous name Detected: Form_Current

I do however have another 'Private Sub Form_Current()' and that works fine... Wow I need a course in this!

Thanks very much for your help

Regards

Steve
 

Users who are viewing this thread

Back
Top Bottom