VBA Code Stopped Working (1 Viewer)

Reese

Registered User.
Local time
Today, 16:54
Joined
Jan 13, 2013
Messages
387
VBA Code Stopped Working (Please Help!!!!!)

I have been writing some VBA code to set the value of unbound text boxes to the combined values of bound textboxes. The first code that I wrote was this:

Me.FullAddressTxt.Value = [EventStTxt] & " " & [EventCityTxt] & ", " & [EventStateCombo] & " " & [EventZipTxt]
DoCmd.RunCommand acCmdRefresh
Me.FullAddressTxt.SetFocus
DoCmd.RunCommand acCmdCopy
Shell ("Firefox www.mapquest.com")

It worked fine until today. Now it gives a run-time error '2110' and says that Access can't move the focus to FullAddressTxt.

I learned that this stopped working when I re-visited it after some other code didn't work. The purpose of the new code is the same as the first. This is the new code:

Me.PublicEmailTxt.Value = [Forms!"ZooMobile Booking Form-New Client"!Organization] & "; " & [Date_of_Event] & "; " & [Start_Time] & "-" & [End_Time] & "; " & [Event_City] & ", " & [Event_State]

The run-time error with this one is '2465'. I open up the debugger and it's saying that the problem is that Me.PublicEmailTxt.Value is Null. Of course it is; the whole point of the code is to fill it in.

Why is it that a code that used to work no longer works and a code that is based on the same structure doesn't work? And why would the errors be different? The setting values part of the first code still works, so why doesn't it work in the second one?

Please help. Thanks.
 
Last edited:

Reese

Registered User.
Local time
Today, 16:54
Joined
Jan 13, 2013
Messages
387
Oh, and I've already tried Compact & Repair, closing & reopening, as well as opening a backup. The problems continued.
 

MSAccessRookie

AWF VIP
Local time
Today, 16:54
Joined
May 2, 2008
Messages
3,428
Oh, and I've already tried Compact & Repair, closing & reopening, as well as opening a backup. The problems continued.


Two common reasons for this error are:
  1. Access cannot find a control with the right name
  2. Access can find a control with the right name, but the control has .Visible=False or .Enabled=False
Does your application modify the .Visible or .Enabled settings for the Field?

-- Rookie
 

missinglinq

AWF VIP
Local time
Today, 16:54
Joined
Jun 20, 2003
Messages
6,423
I'm thinking that the Square Brackets around

[Forms!"ZooMobile Booking Form-New Client"!Organization]

and/or your reference to the Form is confusing Access. I'd try changing that to

Forms("ZooMobile Booking Form-New Client")![Organization]]

and see what happens.

Linq ;0)>
 

Reese

Registered User.
Local time
Today, 16:54
Joined
Jan 13, 2013
Messages
387
  1. Access cannot find a control with the right name
  2. Access can find a control with the right name, but the control has .Visible=False or .Enabled=False

I already checked the names and they do match, so I don't believe that #1 is the case. As for #2, it may be possible for the Full Address issue. It is Visible=False because I wanted the textbox to be in the background, not something that the user would see or could interact with.

I turned it visible, and that worked for setting the value of FullAddressTxt, but now there's a run-time error '53' and it's saying that there's an error with "Shell ("Firefox www.mapquest.com").

But it had worked before and the box was invisible then, why would it be different now? And why is it now having a problem with the Shell line, when that worked before as well?

The visible thing doesn't work for the email code; that textbox is visible because I was still testing the code. And both boxes are enabled.

I also double-checked the trusted locations and that's still good. And I looked in the VBA References and I couldn't find Firefox in the listing.

Thanks for bringing me one step closer. Do you have any other ideas?
 

Reese

Registered User.
Local time
Today, 16:54
Joined
Jan 13, 2013
Messages
387
I'd try changing that to

Forms("ZooMobile Booking Form-New Client")![Organization]]

Hazaa! That works. I still have the problem with the Shell Firefox part in the other one. Does anyone have any ideas with that?

I'm still confused as to why the code initially worked when I had it invisible. Unless there are any other suggestions, I may just have to set the width of the textboxes to 0 so that they are still invisible to the user.
 

Reese

Registered User.
Local time
Today, 16:54
Joined
Jan 13, 2013
Messages
387
Okay, I'm VERY confused. Now the shell part works (I did NOTHING to change it) but several other parts of the code have stopped working without ANY reason. The only thing that I can think of is the fact that I've been uploading & downloading the file on Google Drive to work on it both at home and at work. Could some kind of corruption be happening?

That can't be it, though, because I just downloaded the file from home onto my work computer, saved it as a different name, opened both and they both have the same errors coming up, even though those parts of the code were working fine just two days ago.

I already checked the trusted locations, I've already compiled and repaired. Both at home and at work.

What the hell is going on!? Please, some one help!
 
Last edited:

Bat17

Registered User.
Local time
Today, 21:54
Joined
Sep 24, 2004
Messages
1,687
The fact you are switching between machines makes me suspect references could be the problem.
I would check your references to make sure that none are missing. I seem to recall having a similar issue when Access would automatically update the links to a new library on one machine then not run on another properly

HTH

Peter
 

Reese

Registered User.
Local time
Today, 16:54
Joined
Jan 13, 2013
Messages
387
That makes sense. What should I be looking for in particular? I imagine anything regarding Outlook & Firefox (since those are outside programs which are referenced in the code) but I have no idea what other kinds of references should be checked. Most of the problems are occurring with code that's just within Access itself (setting the value of a field based on if/then statements, etc.)

Next time I have a chance I'll take a look here at the office. If it works here I'll know that I just need to do the same at home. I'll let you know the results. If anyone else has ideas please let me know & I'll try those if the references doesn't work.
 

Reese

Registered User.
Local time
Today, 16:54
Joined
Jan 13, 2013
Messages
387
Oh, FYI, when running the Debugger while in Design view the errors don't come up. It's only when I try to open the forms in form view or run the commands from form view that the errors occur.

Just thought of that; I don't know if it makes a difference. I took a look at the references but I have no idea what should or shouldn't be checked.
 

Reese

Registered User.
Local time
Today, 16:54
Joined
Jan 13, 2013
Messages
387
Partial hazaa!

Here are Doug Steele's detailed instructions on how to troubleshoot the problem of Missing References:

The instructions on there seem to have taken care of the random problems that were within Access itself. Thank you Bat17 & missinglinq.

Unfortunately part of the original problem is still occurring. Access still keeps coming up with an error on the last line of the following code:

Me.FullAddressTxt.Value = [EventStTxt] & " " & [EventCityTxt] & ", " & [EventStateCombo] & " " & [EventZipTxt]
DoCmd.RunCommand acCmdRefresh
Me.FullAddressTxt.SetFocus
DoCmd.RunCommand acCmdCopy
Shell ("Firefox www.mapquest.com")

It worked originally so I'm still rather confused on that account. Any suggestions?
 

missinglinq

AWF VIP
Local time
Today, 16:54
Joined
Jun 20, 2003
Messages
6,423
Cannot understand how

Shell ("Firefox www.mapquest.com")

ever worked; I believe yYou have to give a complete path to a program when you Shell to it. On my box the path is

C:\Program Files (x86)\Mozilla Firefox\firefox.exe

so this does it:

Code:
Call Shell("C:\Program Files (x86)\Mozilla Firefox\firefox.exe www.mapquest.com")

Linq ;0)>
 
Last edited:

Reese

Registered User.
Local time
Today, 16:54
Joined
Jan 13, 2013
Messages
387
Success! In hindsight I understand why a complete path would be needed but now I too am confused as to why the incomplete path worked in the first place.

On a related note and looking forward into my project: My ultimate goal is to have the database hosted on a server and accessed by multiple computers. I know that there are steps that need to be taken to set that up, which I will get to once I'm at that point.

In regards to calling outside programs, however, will the VBA know to call the program on the "terminal" computer or will it try to call the program using the path on the host server?

If it does the later can I somehow set it to use the correct path on any given computer? That is, of course, assuming that the path would be the same on each computer and that the only change would be which "C" drive is being used.
 
Last edited:

Users who are viewing this thread

Top Bottom