473,383 Members | 1,980 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

<Object variable or With block variable not set>

Why It throw an error of <Object variable or With block variable not set>

set objAccess = GetObject(strMdbPath)
objAccess.DoCmd.SetWarning False
objAccess.DoCmd.OpenReport strReportName, 0
'It is fine until now
objAccess.Application.Run "Function",Arg1,Arg2
'Throw the arror
<Object variable or With block variable not set>

I
Jul 26 '07 #1
4 3459
NeoPa
32,556 Expert Mod 16PB
You have (accidentally) posted this question in the Access Articles section. This is NOT an article.
I'm moving this to the main Access questions forum.

MODERATOR.
Jul 26 '07 #2
NeoPa
32,556 Expert Mod 16PB
Why It throw an error of <Object variable or With block variable not set>

set objAccess = GetObject(strMdbPath)
objAccess.DoCmd.SetWarning False
objAccess.DoCmd.OpenReport strReportName, 0
'It is fine until now
objAccess.Application.Run "Function",Arg1,Arg2
'Throw the arror
<Object variable or With block variable not set>

I
Brian, Where is this code? Is it running from within Access?
Jul 26 '07 #3
nico5038
3,080 Expert 2GB
Hmm, did you try a different name instead of "Function" as it might be a reserved word....
I normally use "fnc" as prefix for a function to have no "reserved words" trouble.

NNic;o)
Jul 27 '07 #4
ADezii
8,834 Expert 8TB
Why It throw an error of <Object variable or With block variable not set>

set objAccess = GetObject(strMdbPath)
objAccess.DoCmd.SetWarning False
objAccess.DoCmd.OpenReport strReportName, 0
'It is fine until now
objAccess.Application.Run "Function",Arg1,Arg2
'Throw the arror
<Object variable or With block variable not set>

I
The following code will run the Function fTest(Arg1, Arg2) in the C:\Test\Test.mdb External Database. The fTest(Arg1, Arg2) Function is declared Publically in a Standard Code Module. It accepts 2 String Arguments, and simply concatenates them with a space in between. The Code is of course simplistic, but my only intention is to demonstrate to you how can Run a Function or Sub-Procedure in an External Database from your Current Database. Good Luck - hope this is what you were looking for.
Expand|Select|Wrap|Line Numbers
  1. Dim strMDBPath As String
  2. 'Can also be Declared at a Modular level if needed. In its present state,
  3. 'objAccess goes out-of-scope as soon as the procedure ends.
  4. Dim objAccess As Access.Application
  5.  
  6. strMDBPath = "C:\Test\Test.mdb"
  7.  
  8. Set objAccess = CreateObject("Access.Application")
  9.  
  10. objAccess.Visible = True            'not required
  11.  
  12. objAccess.OpenCurrentDatabase strMDBPath, False
  13.  
  14. objAccess.Run "fTest", "John", "Doe"
  15.  
  16. objAccess.CloseCurrentDatabase
  17. Set objAccess = Nothing
OUTPUT:
Expand|Select|Wrap|Line Numbers
  1. John Doe
Jul 28 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: JayBrahms | last post by:
Hi there. OK, this is a little bit complicated. I would live to find a different way to do this, but evidentially I am not able to open a Text-File in JAVASCRIPT and fill an Array with the...
0
by: Wolfgang Schwanke | last post by:
Dear usenet, I'm having the following small problem. I've been ask to add some Quicktime panoramas to a website. The author of the panoramas has made two versions of each: One in MOV format,...
6
by: Christopher Benson-Manica | last post by:
(I posted this as a reply to my thread about iframes, but I think it may get mostly ignored there.) http://ataru.gomen.org/files/test.html <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN"...
4
by: KC | last post by:
Could some one explain to me the casting rules for sending generic lists, ex. List<Person>, to a function that accepts List<object>? I cannot get the following easy-cheesy app to work. I get the...
4
by: msnews.microsoft.com | last post by:
hello every one i am using media player in internet explorer but i cannot access it directly in code behind, so do you know a way to access it? <object id="video123"...
5
by: 张韡武 | last post by:
Hello. On one webpage I just worked out, I use svg (by using <object>) for browser that supports svg (firefox), and give an <imginside of <objectas a fallback for IE. ...
9
by: Stephan Steiner | last post by:
Hi I seem to have a bit of trouble understanding one bit of how generics work: In C#, every class automatically derives from object, and inherits a bunch of properties (i.e. ToString()). Thus,...
4
by: Alan Silver | last post by:
Hello, I have an <objecttag that is used to display a Flash file. I would like the whole Flash file to be a link. The obvious thought would be to do this... <a...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.