473,396 Members | 1,963 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,396 software developers and data experts.

'Object variable or With block variable not set'

I keep getting the error 'Object variable or With block variable not set' with the following code. 'i' is integer, ViewOptions is OptionBox.

Any idea what I'm doing wrong?

Expand|Select|Wrap|Line Numbers
  1. For i = 0 To 4
  2.     If ViewOptions.Value = 1 Then
  3.          If i = 0 Then
  4.             If IsNumeric(strCriteria(i)) Then
  5.                 LinkCriteriaFinal = "(" & LinkCriteria(i) & " like " & strCriteria(i) & " &'*' )"
  6.             Else
  7.                 LinkCriteriaFinal = "(" & LinkCriteria(i) & " like '" & strCriteria(i) & "' &'*' )"
  8.             End If
  9.         Else
  10.             If IsNumeric(strCriteria(i)) Then
  11.                 LinkCriteriaFinal = LinkCriteriaFinal & " and (" & LinkCriteria(i) & " like  " & strCriteria(i) & " & '*' )"
  12.             Else
  13.                 LinkCriteriaFinal = LinkCriteriaFinal & " and (" & LinkCriteria(i) & " like  '" & strCriteria(i) & "' & '*' )"
  14.             End If
  15.         End If
  16.     Else
  17.         If i = 0 Then
  18.             If IsNumeric(strCriteria(i)) Then
  19.                 LinkCriteriaFinal = "(" & LinkCriteria(i) & " like " & strCriteria(i) & " &'*' )"
  20.             Else
  21.                 LinkCriteriaFinal = "(" & LinkCriteria(i) & " like '" & strCriteria(i) & "' &'*' )"
  22.             End If
  23.         Else
  24.             If IsNumeric(strCriteria(i)) Then
  25.                 LinkCriteriaFinal = LinkCriteriaFinal & " or (" & LinkCriteria(i) & " like  " & strCriteria(i) & " & '*' )"
  26.             Else
  27.                 LinkCriteriaFinal = LinkCriteriaFinal & " or (" & LinkCriteria(i) & " like  '" & strCriteria(i) & "' & '*' )"
  28.             End If
  29.         End If
  30.      End If
  31. Next i
Mar 5 '07 #1
8 18416
Killer42
8,435 Expert 8TB
Where in this code is the error happening?

If it's pointing to ViewOptions.Value then we probably need to know more about what ViewOptions is, and how it's defined. Also, what version of VB is this?
Mar 5 '07 #2
I'm not sure where the error is occurring, how can I tell?
Mar 5 '07 #3
I'm using Access 97. ViewOptions is an Option Box with two radio buttons, one with value of 1 and the other with value of 2. I have it defined as follows: Dim ViewOptions As OptionGroup
Mar 5 '07 #4
Killer42
8,435 Expert 8TB
I'm not sure where the error is occurring, how can I tell?
Doesn't Access stop and point to the line of code when it reports the error?
Mar 6 '07 #5
Killer42
8,435 Expert 8TB
I'm using Access 97. ViewOptions is an Option Box with two radio buttons, one with value of 1 and the other with value of 2. I have it defined as follows: Dim ViewOptions As OptionGroup
I'm having a little trouble getting this straight in my mind. Do you have an option group on the form which you created through the GUI, or one which you created in code with the Dim statement, or both?

I suspect that the answer to this will provide the answer to your problem.
Mar 6 '07 #6
vijaydiwakar
579 512MB
Dear the error 'Object variable or With block variable not set' is occured where ur using an object without allocating memory for it. so i've seen one line that is always use new keyword to allocate the memory for any object or use set keyword to do so
try it
Mar 6 '07 #7
I'm having a little trouble getting this straight in my mind. Do you have an option group on the form which you created through the GUI, or one which you created in code with the Dim statement, or both?

I suspect that the answer to this will provide the answer to your problem.

I deleted the Dim statement and it works just fine!

Thank you so much!
Mar 6 '07 #8
Killer42
8,435 Expert 8TB
I deleted the Dim statement and it works just fine!
Thank you so much!
Glad we could help. :)
Mar 6 '07 #9

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

Similar topics

8
by: Lauren Quantrell | last post by:
I get the following error: "Object variable or Width block variable not set error" trying to run this in my Access2000 .ADP database: CurrentDb.Properties.Append...
1
by: JMCN | last post by:
hello- i received an runtime error message: You tried to call Update or CancelUpdate or attempted to update a Field in a recordset without first calling AddNew or Edit. (Error 3020). when i look...
4
by: nelsonchang | last post by:
Dear all, I wrote the VB code in a "button press event" as below in which is retrieve data from SQL server and insert the data into Excel. After that, I would call Excel "subtotal" API to build a...
6
by: Neo Geshel | last post by:
I am trying to deal with an image in code-behind. I consistently get the following error: Server Error in '/' Application. Object variable or With block variable not set. Description: An...
3
by: Richard Hollenbeck | last post by:
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...
9
by: axs221 | last post by:
I am trying to move some of our large VBA Access front-end file into ActiveX DLL files. I created two DLL files so far, one was a module that contains code to integrate into the QuickBooks...
2
by: vbLeo | last post by:
Hello Guys, I'm trying to dynamically create forms and add controls to them. I'm specifically having a problem with establishing a data source for my textbox. I am able to add a remote data...
1
by: abhijmenbumca07 | last post by:
Object variable or With block variable not set. Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information...
4
by: BrianAdev | last post by:
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...
3
by: Newbie19 | last post by:
I'm trying to get a list of all subfolders in a folder on a share drive, but I keep on getting this error message: Object variable or With block variable not set. Description: An unhandled...
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:
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
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...
0
tracyyun
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...

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.