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

Run-time error '424': Object required - can't work out why

Hi all,

I'm running a VERY simple bit of code that is supposed to set the
record source of the current form based on the entries in two unbound
fields to act as a rudimentary search tool.

The code is as follows... excuse my over use of ifs and thens but its
the only way my brain will logically work out what i am doing.

***Code Segment***

Private Sub Search_Click()

Dim strSQL As String, UserLogged As String

strSQL = ""

strSQL = "SELECT * FROM tblIncidents "

If (((Me.IDSearch = "") Or (Me.IDSearch Is Null)) And
((Me.KeywordSearch = "") Or (Me.KeywordSearch Is Null))) Then
'do nowt
Else
strSQL = strSQL & "WHERE "
End If

If Me.IDSearch = "" Or Me.IDSearch Is Null Then
'do nowt
Else
strSQL = strSQL & "(incidentid = '" & Me.IDSearch & "') "
End If

If (Me.IDSearch = "" Or Me.IDSearch Is Null) Then
'do nowt
Else
strSQL = strSQL & "AND "
End If

If Me.KeywordSearch = "" Or Me.KeywordSearch Is Null Then
'do nowt
Else
strSQL = strSQL & "(incidenttitle LIKE '*" & Me.KeywordSearch &
"*') "
End If

strSQL = strSQL & ";"

Me.RecordSource = strSQL

End Sub

***End Code Segment***

The Error message appears on the fifth line:

If (((Me.IDSearch = "") Or (Me.IDSearch Is Null)) And
((Me.KeywordSearch = "") Or (Me.KeywordSearch Is Null))) Then

right at the very beginning of the code. I can't understand why as the
objects in this simple line are all in scope as far as i can tell.

Any good ideas?

Rob.

Nov 13 '05 #1
3 11185
dkintheuk wrote in message
<11*********************@f14g2000cwb.googlegroups. com> :
Hi all,

I'm running a VERY simple bit of code that is supposed to set the
record source of the current form based on the entries in two unbound
fields to act as a rudimentary search tool.

The code is as follows... excuse my over use of ifs and thens but its
the only way my brain will logically work out what i am doing.

***Code Segment***

Private Sub Search_Click()

Dim strSQL As String, UserLogged As String

strSQL = ""

strSQL = "SELECT * FROM tblIncidents "

If (((Me.IDSearch = "") Or (Me.IDSearch Is Null)) And
((Me.KeywordSearch = "") Or (Me.KeywordSearch Is Null))) Then
'do nowt
Else
strSQL = strSQL & "WHERE "
End If

If Me.IDSearch = "" Or Me.IDSearch Is Null Then
'do nowt
Else
strSQL = strSQL & "(incidentid = '" & Me.IDSearch & "') "
End If

If (Me.IDSearch = "" Or Me.IDSearch Is Null) Then
'do nowt
Else
strSQL = strSQL & "AND "
End If

If Me.KeywordSearch = "" Or Me.KeywordSearch Is Null Then
'do nowt
Else
strSQL = strSQL & "(incidenttitle LIKE '*" & Me.KeywordSearch &
"*') "
End If

strSQL = strSQL & ";"

Me.RecordSource = strSQL

End Sub

***End Code Segment***

The Error message appears on the fifth line:

If (((Me.IDSearch = "") Or (Me.IDSearch Is Null)) And
((Me.KeywordSearch = "") Or (Me.KeywordSearch Is Null))) Then

right at the very beginning of the code. I can't understand why as the
objects in this simple line are all in scope as far as i can tell.

Any good ideas?

Rob.


I don't know for sure what causes the error, but in the following line
If (((Me.IDSearch = "") Or (Me.IDSearch Is Null)) And
((Me.KeywordSearch = "") Or (Me.KeywordSearch Is Null))) Then

you are testing with SQL syntax, rather than VB(A) syntax. In VBA,
use the IsNull function, or for instance combine the tests like this

if len(Me!IDSearch.value & "") = 0 then
' either Null or ""
end if

But do also ensure you've got correct spelling, too

--
Roy-Vidar

Nov 13 '05 #2
"dkintheuk" <rm*******@firenet.uk.com> wrote in message
news:11*********************@f14g2000cwb.googlegro ups.com...

The Error message appears on the fifth line:

If (((Me.IDSearch = "") Or (Me.IDSearch Is Null)) And
((Me.KeywordSearch = "") Or (Me.KeywordSearch Is Null))) Then

right at the very beginning of the code. I can't understand why as the
objects in this simple line are all in scope as far as i can tell.

Well "Is Null" is a SQL test, you could try using the "IsNull" VBA test.
There seem to be a lot of brackets there too.

If (Me.IDSearch = "" Or IsNull(Me.IDSearch)) And (Me.KeywordSearch = "" Or
IsNull(Me.KeywordSearch)) Then

Regards,
Keith.
www.keithwilby.com
Nov 13 '05 #3
So blinking obvious - you're dead right of course. Got my syntax mixed
up... shouldn't have had the last beer last night.

Thanks,

Rob.

Nov 13 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
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...
7
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...
5
by: Thomas | last post by:
I am using php 5.0.4 under IIS 6 under Windows Server 2003 and want to run a php-script as a separate process. This schript dies not have any output. I tried several variants without success: ...
5
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...
2
by: Zeno Lee | last post by:
I'm using File.Exists to test a file on my C: drive. My program was strongly named and had caspol -af run on it to allow it to run from the network. There are 3 ways I am doing this: 1) Run...
8
by: Tim | last post by:
Is it possible to close the form I invoked via Application.Run() as I invoke another form without the application exiting? (I'd rather not hide it since I don't need it anymore) ....call to...
3
by: Nx | last post by:
Hello I think my question is how to make the script wait until it returns from a call to run() Here is a code snippet: # next lines calls python2.4 32 bit version # from a script running...
0
by: cn.popeye | last post by:
Use UltraEdit run Python Run UltraEdit Menu :Advanced menu/Tool Configuration command Command Line: python %n%e Working Directory:%p
0
by: modularmix | last post by:
Does anyone know how to run the Excel Macro for two different spreadsheets in parallel. Here is the code that works sequentially. Workbooks.Open Filename:="C:\Documents and...
1
by: GaryDean | last post by:
We have a new server2003 machine that was built like all the rest - IIS and everything needed to run asp.net apps. We have a test asp.net website that we use for new machines to make sure...
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: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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...

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.