Re: Multi Field SQL Where Clause
- From: Hank@ieultd <Hankieultd@xxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 6 Jul 2006 18:12:01 -0700
Hello Again Steve;
I haven't given up yet of course so here goes.
The triple quotes cause a syntax error. When I remove the two additional
quotes the syntax error goes away but the functionality is still absent.
Do the definitions have to be DIM rather than PUBLIC as in
Public sysNtCoNo as Single
Public sysNtDvNo as Single
Public sysNtLcCd as Single
Public sysNtApLkNo as Long
etc.
Note the co/dv & lc are single fixed fields. I don't know if that makes a
difference with the quotes within the string or not.
Also note, when using the string as you have defined it the correct values
are displayed so it has to be close to correct. Just can't identify the
obvious probably.
Thanks Again for all your help!!!
hank
"SteveS" wrote:
Hi Hank,
First, open a code window, then in the menu bar, click on TOOLS/OPTIONS.
Click on the Editor tab, then UNCHECK "Auto Syntax Check". This option just
causes a dialog to appear when there is a syntax error. The error turns red,
so there is no need for the additional warning (in my opinion).
Next, CHECK "Require Variable Declaration". This adds a line to any NEW module
created that requires variables to be DIM'ed. Any new module will have as the
first two lines:
Option Compare Database
Option Explicit
Now for the code.
I can tell that "sysNtSysCd" and "sysNtAplCd" are strings and "sysNtApLkLn" and
"sysNtLn" are integers.
What data types are these variables: (String, Integer, Long, etc.)
sysNtCoNo
sysNtDvNo
sysNtLcCd
sysNtApLkNo
You almost have it. The where clause needs a little different.
Look at the variable "strWhere" in the following modified code. (I changed
'NotesSelectCriteria' to 'strWhere')
(watch for line wrap)
'************************************
Option Compare Database
Option Explicit
Public Function DisplayNotes()
Dim sysNtSysCd As String
Dim sysNtAplCd As String
'this was 'NotesSelectCriteria'
Dim strWhere As String
Dim sysNtCoNo As Integer
Dim sysNtDvNo As Integer
Dim sysNtLcCd As Integer
Dim sysNtApLkNo As Integer
Dim sysNtApLkLn As Integer
Dim sysNtLn As Integer
'initialize
sysNtSysCd = "PU"
sysNtAplCd = "OHNT" '< removed a training space
sysNtCoNo = sysPUOHCoNo
sysNtDvNo = sysPUOHDvNo
sysNtLcCd = sysPUOHLcCd
sysNtApLkNo = sysPUOHNo
sysNtApLkLn = 0
sysNtLn = 1
'create the Where clause
'these are strings
strWhere = "[NtSysCd] = '" & [sysNtSysCd] & "' And "
strWhere = strWhere & "[NtAplCd] = '" & [sysNtAplCd] & "' And "
'and these are numeric
strWhere = strWhere & "[NtCoNo] = " & [sysNtCoNo] & " And "
strWhere = strWhere & "[NtDvNo] = " & [sysNtDvNo] & " And "
strWhere = strWhere & "[NtLcCd] = " & [sysNtLcCd] & " And "
strWhere = strWhere & "[NtApLkNo] = " & [sysNtApLkNo] & " And """
strWhere = strWhere & "[NtApLkLn] = " & [sysNtApLkLn]
'------ for debugging only ------------
MsgBox NotesSelectCriteria
'---------------------------------
sysform = "NtMaint"
'syntax
'DoCmd.OpenForm formname[, view][, filtername][, wherecondition][,
datamode][, windowmode][, openargs]
DoCmd.OpenForm sysform, , , strWhere
End Function
'************************************
HTH
--
Steve S.
--------------------------------
"Veni, Vidi, Velcro"
(I came, I saw, I stuck around.)
.
- Follow-Ups:
- Re: Multi Field SQL Where Clause
- From: SteveS
- Re: Multi Field SQL Where Clause
- From: Hank@ieultd
- Re: Multi Field SQL Where Clause
- References:
- Re: Multi Field SQL Where Clause
- From: SteveS
- Re: Multi Field SQL Where Clause
- From: SteveS
- Re: Multi Field SQL Where Clause
- Prev by Date: Re: Search Through a Data Base
- Next by Date: Re: Goto Control - syntax for argument
- Previous by thread: Re: Multi Field SQL Where Clause
- Next by thread: Re: Multi Field SQL Where Clause
- Index(es):
Relevant Pages
|
Loading