I've marked the line in this subroutine where I've been getting this error.
It may be something stupid but I've been staring at this error trying to fix
it for over an hour. I'm pretty sure the table and field names and controls
are all named correctly, and the control referred to in the errant code is
open, and it has data in it.
Private Sub cmdAddIngredien tToRecipe_Click ()
' Get RecipeID for future action query
Dim recipeID As Long
Dim dbGetRecipeID As DAO.Database
Dim rsGetRecipeID As DAO.Recordset
Dim StrSQL As String
Set dbGetRecipeID = CurrentDb()
StrSQL = "SELECT tblRecipes.lngR ecipeID FROM tblRecipes WHERE
(((tblRecipes.l ngRecipeID)= " & [Forms]![frmRecipes]![lngRecipeID] & "));"
Set rsGetRecipeID = dbGetRecipeID.O penRecordset(St rSQL, dbOpenDynaset)
recipeID = rsGetRecipeID.F ields(0)
Set rsGetRecipeID = Nothing
Set dbGetRecipeID = Nothing
' This works fine to this point
' Get IngredientID for future action query
Dim IngredientID As Long
Dim dbGetIngredient ID As DAO.Database
Dim rsGetIngredient ID As DAO.Recordset
'I'm filling variables to use in an append query down later in this
subroutine.
StrSQL = "SELECT tblIngredients. lngIngredientID FROM tblIngredients
WHERE tblIngredients. IngredientName = '" & cboIngredientNa me & "'"
'IngredientName is a text field.
' The next line is flagged as a problem. I get a run-time error 91" Object
Variable
' or with block variable not set. I'm predicting something is wrong with my
SQL statament on the previous line.
Set rsGetIngredient ID = dbGetIngredient ID.OpenRecordse t(StrSQL,
dbOpenDynaset)
IngredientID = rsGetIngredient ID.Fields(0)
Set rsGetRecipeID = Nothing
Set dbGetRecipeID = Nothing
MsgBox IngredientID 'just to test my code this far.
End Sub 3 35509
Richard Hollenbeck wrote: I've marked the line in this subroutine where I've been getting this error. It may be something stupid but I've been staring at this error trying to fix it for over an hour. I'm pretty sure the table and field names and controls are all named correctly, and the control referred to in the errant code is open, and it has data in it.
Private Sub cmdAddIngredien tToRecipe_Click ()
' Get RecipeID for future action query Dim recipeID As Long Dim dbGetRecipeID As DAO.Database Dim rsGetRecipeID As DAO.Recordset Dim StrSQL As String Set dbGetRecipeID = CurrentDb()
StrSQL = "SELECT tblRecipes.lngR ecipeID FROM tblRecipes WHERE (((tblRecipes.l ngRecipeID)= " & [Forms]![frmRecipes]![lngRecipeID] & "));"
Set rsGetRecipeID = dbGetRecipeID.O penRecordset(St rSQL, dbOpenDynaset) recipeID = rsGetRecipeID.F ields(0)
Set rsGetRecipeID = Nothing Set dbGetRecipeID = Nothing
' This works fine to this point
' Get IngredientID for future action query
Dim IngredientID As Long Dim dbGetIngredient ID As DAO.Database Dim rsGetIngredient ID As DAO.Recordset
'I'm filling variables to use in an append query down later in this subroutine.
StrSQL = "SELECT tblIngredients. lngIngredientID FROM tblIngredients WHERE tblIngredients. IngredientName = '" & cboIngredientNa me & "'"
'IngredientName is a text field.
' The next line is flagged as a problem. I get a run-time error 91" Object Variable ' or with block variable not set. I'm predicting something is wrong with my SQL statament on the previous line.
Set rsGetIngredient ID = dbGetIngredient ID.OpenRecordse t(StrSQL, dbOpenDynaset)
The 91 error is indicating that an object variable is not set to a value, i.e. it is
"Nothing".
Looking at the line where the error occurs shows that you are setting the
rsGetIngredient ID object to contain a reference to a recordset. This line depends on
another object - "dbGetIngredien tID".
Looking at the code I see that this is defined with:
Dim dbGetRecipeID As DAO.Database
so it is defined to be a reference to a DAO Database object. However, I don't see where
you actually instantiated this object; i.e. you don't have a line like:
Set dbGetRecipeID = CurrentDb()
or
Set dbGetRecipeID = dbEngine.OpenDa tabase(...)
so that would explain the "Object variable is not set" message.
--
'---------------
'John Mishefske
'---------------
"John Mishefske" <jm**********@S PAMyahoo.com> wrote in message
news:hY******** **********@torn ado.rdc-kc.rr.com... Richard Hollenbeck wrote: I've marked the line in this subroutine where I've been getting this error. It may be something stupid but I've been staring at this error trying to fix it for over an hour. I'm pretty sure the table and field names and controls are all named correctly, and the control referred to in the errant code is open, and it has data in it.
Private Sub cmdAddIngredien tToRecipe_Click ()
' Get RecipeID for future action query Dim recipeID As Long Dim dbGetRecipeID As DAO.Database Dim rsGetRecipeID As DAO.Recordset Dim StrSQL As String Set dbGetRecipeID = CurrentDb()
StrSQL = "SELECT tblRecipes.lngR ecipeID FROM tblRecipes WHERE (((tblRecipes.l ngRecipeID)= " & [Forms]![frmRecipes]![lngRecipeID] & "));"
Set rsGetRecipeID = dbGetRecipeID.O penRecordset(St rSQL, dbOpenDynaset) recipeID = rsGetRecipeID.F ields(0)
Set rsGetRecipeID = Nothing Set dbGetRecipeID = Nothing
' This works fine to this point
' Get IngredientID for future action query
Dim IngredientID As Long Dim dbGetIngredient ID As DAO.Database Dim rsGetIngredient ID As DAO.Recordset
'I'm filling variables to use in an append query down later in this subroutine.
StrSQL = "SELECT tblIngredients. lngIngredientID FROM tblIngredients WHERE tblIngredients. IngredientName = '" & cboIngredientNa me & "'"
'IngredientName is a text field.
' The next line is flagged as a problem. I get a run-time error 91" Object Variable ' or with block variable not set. I'm predicting something is wrong with my SQL statament on the previous line.
Set rsGetIngredient ID = dbGetIngredient ID.OpenRecordse t(StrSQL, dbOpenDynaset)
The 91 error is indicating that an object variable is not set to a value, i.e. it is "Nothing".
Looking at the line where the error occurs shows that you are setting the rsGetIngredient ID object to contain a reference to a recordset. This line depends on another object - "dbGetIngredien tID".
Looking at the code I see that this is defined with:
Dim dbGetRecipeID As DAO.Database
so it is defined to be a reference to a DAO Database object. However, I don't see where you actually instantiated this object; i.e. you don't have a line like:
Set dbGetRecipeID = CurrentDb()
or
Set dbGetRecipeID = dbEngine.OpenDa tabase(...)
so that would explain the "Object variable is not set" message.
-- '--------------- 'John Mishefske '---------------
Thank you. That at least changed something. I added the code:
"Set dbGetIngredient ID = CurrentDb()" without the quotes just before the
second SQL statement. Now I'm not getting that error 91 anymore. Now I'm
getting error 3021, "no current record". But the related forms are open and
pointed at valid records. Hey at this point any change is progress. :-)
I'll double check that my practice query (that works by the way) is closed
then try again.
"Richard Hollenbeck" <ri************ ****@verizon.ne t> wrote in message
news:YiJog.6211 $il.3902@trnddc 03... "John Mishefske" <jm**********@S PAMyahoo.com> wrote in message news:hY******** **********@torn ado.rdc-kc.rr.com... Richard Hollenbeck wrote:
Problem solved. In addition to forgetting to set the db as the currentdb(),
I was looking for a single value but had multiple columns in the combobox.
Fixed that and everything went well after that. Now on to the next problem.
I'll try to figure it out first.
Thanks for all the help.
Rich This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: leroybt.rm |
last post by:
Can someone tell me how to run a script from a interactive shell
I type the following:
>>>python filename
>>>python filename.py
>>>run filename
>>>run filename.py
>>>/run filename
>>>/run filename.py
|
by: Mactash |
last post by:
Folks,
I am trying just to run a simple asp commands in the
Internet Explorer. ( I have windows XP)
When I run this asp lines on ASP Matrix web server it is
ok.
But, when I run this on IIS it acts like the asp engine
is not working.
|
by: PW |
last post by:
How can I run a DOS command from my ASP ?
(prefer to use html/vbscript solution rather than 3rd party add-ons)
|
by: SiuLoBow |
last post by:
Hi,
Is there anyway to detect the ActiveX control is able to run on the browser
or not?
After I installed the ActiveX control to my system, user sometimes switch
the secruity setting to "not able to run ActiveX control". So, the ActiveX
control just show on the broswer, but not able to run it.
I want to find a way to detect it. And prompt the user a message telling
|
by: Napo |
last post by:
Hi:
i build a .net application named A.exe. I need run this application
twice using c# code in another application. i try to use
process.start(A.exe) twcie, but it failed. Because the second start will use
the existed process. So only one application run.
I can use mouse to run this application twice, and there are two A.exe
processes in processed pool. So how can i do the same work using code but not
manu-click?
| |
by: Piotr Lipski |
last post by:
I have two servers: progress as transational server and mssql as warehouse
server.
I did DTS that "pumps" data from progress to mssql (via ODBC). Copying the
data has to be done once a day, but sometimes there is a need to do it on
user's demand.
I'd like to ensure that I properly understood the method of running DTS I've
just found using Google.
|
by: erniedude |
last post by:
Hi,
I'm a newbie and I was wondering if anyone knew a (Python) script to
run 4 batch files, one after the other (assuming the directories are
known). It would be better if all 4 batch files could run
simultaneously, but that might break Windows... ;) The problem I had
was I couldn't get the files to RUN, only to OPEN. Thanks for the
help!!!
pseudo-code looks like this
|
by: Adrian |
last post by:
Hi
I want to be able to start a locally installed application from within a
web page.
So if our application is installed it is started when a user clicks a link
on our page. I know or assume this cannot be done just from JS?
I though I could do it using an OCX active (signed) and then call it from JS
using onclick but can't seem to get this to work!
|
by: Nemok |
last post by:
Hi,
Is it possible in anyway to load a file into memory and then run it
from there? I am working on a file compressor
(www.nemokprod.go.ro/nb.htm) that can compress and encrypt and save
multiple files as an exe file that can then run the compressed files
after unpacking them to a temp folder. The problem is that I have to
unpack the files to the hard-disk and then run them from there, making
them vulnerable to user that may try to get...
|
by: nephish |
last post by:
hey there all,
i have been looking for a way to run a php command line script from my
python script.
here is what i want to do:
if x = 4:
execute php4 testin.php
else:
execute php4 testout.php
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |