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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Convert VBA to Macro

Status
Not open for further replies.

cairo207

IS-IT--Management
Jan 2, 2003
13
Need help to convert VBA to Macro. A combo box, named cboSelect, selects a record to view but I am forever receiving a Network problem. Can anyone assist in converting the following:

Private Sub cboSelect_AfterUpdate()
' Find the record that matches the control.
Dim rs As Object

Set rs = Me.Recordset.Clone
rs.FindFirst "[EvalNo] = " & Str(Me![cboSelect])
Me.Bookmark = rs.Bookmark
End Sub

to a macro which I hope will not encounter this recurring network problem?

Thanks
 
Why do you think a macro will not encounter network problem?

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
How are ya cairo207 . . .

You can convert [blue]VBA[/blue] to [blue]Macro[/blue], not the other way around! Why would you want to? [surprise]

Calvin.gif
See Ya! . . . . . .

Be sure to see thread181-473997
Also faq181-2886
 
Thanks for the responses. I agree I would normally go for VBA everytime but in this case the VBA is not working due to some network problem which does not appear to affect the macros. Just thought that as a workaround I could convert the VBA to Macros to ensure the database is workable.

 
The network thingie - probably something saying network connection is lost bla bla, is most likely a sign that your db is in some state of corruption.

Try following the following steps

1 close all instances of access
2 in Start | Run, type or copy/paste from address bar of explorer:
msaccess /decompile "c:\<full path and name of db>.mdb/accdb"
3 while holding SHIFT hit OK
4 when you see database window/navigation pain, close the db
5 while holding SHIFT open the database again
6 while holding SHIFT do Compact & Repair.
In 2007: Office-button | Manage
Previous versions Tools | Database Utilities
7 enter any module, hit Debug | Compile, then save and test again.
(8 Compact repair without running code again)

The issue with holding the SHIFT key, is to ensure no code is running.

There are more ways of dealing with corruption, too, but the above has fixed most of my issues.

Roy-Vidar
 
RoyVidar,

If you do a compact and repair, doesn't it disable code from running when it's doing it's thing anyway, since it isn't opening the database normally anyway? Or are you saying so that the code won't run AFTER the compact and repair?

--

"If to err is human, then I must be some kind of human!" -Me
 
Try adding a startup form, with the following code in the forms on open even:

[tt]msgbox "oups"[/tt]

then, from within the database, run a compact & repair without holding SHIFT.

if you're right, no oups...

If some code is running while doing /decompile or compact repair when Access is trying to fix it, it's no point in doing any of them, as running code will force re-compilation of code, thus keep the corrupted part of the compiled code.

Roy-Vidar
 
RoyVidar,

I tried that, and best I could tell, it did load, but only AFTER the Compact and Repair had run.

--

"If to err is human, then I must be some kind of human!" -Me
 
#7 says use Debug | Compile -> meaning the whole project

Allowing compact & repair to run code prior to doing a full compile, means that Access will do a compile of some parts of the code to some degree. I e - some parts of the code will be in one of the 11 states or levels between uncompiled and fully compiled p code

Due to how objects and code in a2k+ versions are stored, running unsaved and uncompiled code, sometimes also causes courruption (which could possibly be the case here, too), which makes this is a baaaaad thing.

Roy-Vidar
 
[blush] Just ignore my question, RoyVidar, I was thinking Compact and Repair, not Debug-Compile - totally different idea there - oops! [WINK]

--

"If to err is human, then I must be some kind of human!" -Me
 
Thanks for the responses. Fortunately the database wasn't that large so ended up reconstructing it. It appears to be working fine with the VBA.

Cheers,

Cairo207
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top