Solved Convert Form's Macros to VB not working (1 Viewer)

anski

Registered User.
Local time
Today, 17:49
Joined
Sep 5, 2009
Messages
93
My form has SEVERAL macros and I used the 'Convert Form's Macros to VB.' Sadly, the actions stopped working.

So I created a simple form to try to figure out the error. I created a macro on a field's On Mouse Down event: Message Box. Macro worked fine. Then I used the Convert Form's Macros to VB. The action does not work. I checked the Event Procedure, there are no duplicate names.

This is what the Convert Form's Macros to VB created:
'------------------------------------------------------------
' ddate_MouseDown
'
'------------------------------------------------------------
Private Sub ddate_MouseDown(Button As Integer, Shift As Integer, X As Double, Y As Double)

Beep
MsgBox "hello", vbOKOnly, ""

End Sub


I have attached the error message.

I also tried to Compile and I get the same error.
1670169182648.png

1670169527120.png
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 05:49
Joined
Feb 19, 2002
Messages
43,302
Sounds like corruption somewhere. Try the usual = C&R, decompile, copy all objects to new FE.
 

ebs17

Well-known member
Local time
Today, 11:49
Joined
Feb 7, 2020
Messages
1,949
The macro with the same name is deleted?
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 10:49
Joined
Jul 9, 2003
Messages
16,282
This is not an answer to your particular problem, but something which I'm sure you would like to be aware of.

The conversion of macros to VBA does not always work correctly. See my blog here for more information.


If your macro refers to the contents of an object, for example, a textbox, then the conversion will assume that you meant the actual text box control (an object) "Not" it's contents (its value).

The mistake the conversion makes is omitting the value, which is usual practice for developers, as value is the "Default" and not required. (Except in this unusual case)
 

anski

Registered User.
Local time
Today, 17:49
Joined
Sep 5, 2009
Messages
93
Sounds like corruption somewhere. Try the usual = C&R, decompile, copy all objects to new FE.
I did but still did not work. I could not get past the decompile process as it was pointing to the same issue. The form involved is also going to be used as subforms (but with a different table source) in other forms. Updating the name of the header forms in all the macros was cumbersome so I decided to use the Convert Form's Macro to VBA, and I could just use the Replace function to change the header form names. Sadly, this Access feature seems to be problematic.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:49
Joined
May 7, 2009
Messages
19,247
you Replace "Double" (without quote) with "Single" (without quote).
that is the correct declaration.
 

anski

Registered User.
Local time
Today, 17:49
Joined
Sep 5, 2009
Messages
93
you Replace "Double" (without quote) with "Single" (without quote).
that is the correct declaration.
oh wow. that worked! i will try this with the real form and the several embedded macros. thanks a lot!
 

Users who are viewing this thread

Top Bottom