I am having trouble getting the procedure to use a Multiselect listbox in a
report to work. I am using Access 2000.
Here's the code. The error I get is QueryDef "User-defined type not
defined".
Private Sub CmdReport_Click ()
On Error GoTo Err_CmdReport_C lick
Dim stDocName, stSQL, stWhat, stCriteria As String
Dim varItem As Variant
Dim qdfTemp As QueryDef
stWhat = ""
stCriteria = ","
For Each varItem In Me!List1.ItemsS elected
stWhat = stWhat & "'" & Me!List1.ItemDa ta(varItem) & "'"
stWhat = stWhat & stCriteria
Next varItem
Me!HiddenTextBo x = CStr(Left$(stWh at, Len(stWhat) -
Len(stCriteria) ))
Set qdfTemp = CurrentDb.Query Defs("qryInvent ory")
stSQL = "SELECT Position, Line, Station, Status "
stSQL = stSQL & "FROM tblInventory WHERE Position"
stSQL = stSQL & " IN (" & Me!HiddenTextBo x & ")"
qdfTemp.SQL = stSQL
qdfTemp.Close
stDocName = "tblInvento ry"
DoCmd.OpenRepor t stDocName, acPreview, qryInventory
Exit_CmdReport_ Click:
Exit Sub
Err_CmdReport_C lick:
MsgBox Err.Description
Resume Exit_CmdReport_ Click
End Sub
Please advise and thanks, much!!
Bill Walsh 1 1902 wa********@sbcg lobal.net wrote: I am having trouble getting the procedure to use a Multiselect listbox in a report to work. I am using Access 2000.
Here's the code. The error I get is QueryDef "User-defined type not defined".
Private Sub CmdReport_Click () On Error GoTo Err_CmdReport_C lick
Dim stDocName, stSQL, stWhat, stCriteria As String Dim varItem As Variant Dim qdfTemp As QueryDef
stWhat = "" stCriteria = ","
For Each varItem In Me!List1.ItemsS elected stWhat = stWhat & "'" & Me!List1.ItemDa ta(varItem) & "'" stWhat = stWhat & stCriteria Next varItem
Me!HiddenTextBo x = CStr(Left$(stWh at, Len(stWhat) - Len(stCriteria) )) Set qdfTemp = CurrentDb.Query Defs("qryInvent ory") stSQL = "SELECT Position, Line, Station, Status " stSQL = stSQL & "FROM tblInventory WHERE Position" stSQL = stSQL & " IN (" & Me!HiddenTextBo x & ")" qdfTemp.SQL = stSQL qdfTemp.Close
stDocName = "tblInvento ry"
DoCmd.OpenRepor t stDocName, acPreview, qryInventory
Exit_CmdReport_ Click: Exit Sub
Err_CmdReport_C lick: MsgBox Err.Description Resume Exit_CmdReport_ Click
End Sub
Please advise and thanks, much!!
Bill Walsh
It might help if you put in a comma between each element.
Example
stWhat = stWhat & stCriteria & ", "
and at the end of adding elements, remove the comma and space.
Hint: When you have created a SQL string that fails, enter
Debug.Print yourSQLStringVa riable
Then run, then go into the Debug/Immediate window and copy the SQL
string. Open a new query in design mode, don't add any tables, and go
into SQL view. Paste the SQL into the window and try to run. Your
error will most likely be very evident. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: louise |
last post by:
hi
i am trying to set up a mail merge button which takes records from a
multi-select listbox (the contents of which are decided by a query
created by a search from) and not from a specific query.
I have a function GetCriteria()
Private Function GetCriteria() As String
Dim stDocCriteria As String
|
by: Peder Y |
last post by:
I'm making an ownerdrawn multiselect multiextended ListBox where I'm
calling the DrawItem event in my code on specific events and need to
make my own DrawItemEventArgs. However, when do I need to pass on the
"Focused"-property? The problem is that when I use the arrow keys to
navigate the items, sometimes the FocusRectangle skips ahead or lags
behind when I pass the Item over which the mouse hovers. Anyone knows
how to find the focused...
|
by: ¿ Mahesh Kumar |
last post by:
Hi groups,
Control name : ListboxID (lstCertification), selection mode=mutliselect.
On Pageload i'm assinging string lstSplit="1/3/6/8" of the previously selected listindex id's. Now on the page load for updation, i have to reload the selected items again with the same string "1/3/6/8" to be selected in my multiselect list box.
Its asking me to convert object to int... for list selection. but how to achieve this..?...
|
by: ML |
last post by:
I have used Allen Brown's technique for filling a listbox on a form with the
names of files in a certain disc folder.
It works well.
I am now giving the user the option to print the form contents in a report
which has the same fields as the form.
All fields derived from report query are OK
A listbox with design mode rowsource setting, works fine BUT...
|
by: ttime |
last post by:
I've got a form that uses a multiselect listbox. When a user is selected from a combo box, values are populated into this listbox associated with that user.
The problem is, if one person has say 10 entries in the listbox, and selects the last 3-4, and the next user only has 2 entries, those last 3-4 rows are still highlighted in the listbox. This introduces null values into my code which is definitely not good.
I've tried using...
| |
by: IMK |
last post by:
Hello all,
Sorry if this issue has come up already but I am new to vb.net.
Thanks.
I am trying to retrieve the selectedvalues from a multiselect list box
in a vb 2005 winform. Here is the code I am using so far:
dim i as object
For Each i In Me.lstUnitPicklist.SelectedItems
|
by: kaosyeti via AccessMonster.com |
last post by:
hey... i have an unbound multiselect listbox on a form that i want to use to
populate text boxes on that form. so if a user selects the 3rd item in a
list of 20, how can i have that item show up in a text box? then, how can i
have a second selected item show up in a different text box, without
affecting the 1st one? (lboxOptions, txtboxOptions0, txtboxOptions1, etc..)
--
Greg
Message posted via AccessMonster.com
|
by: jschmidt |
last post by:
Hello Everyone,
I have an access application that has a listbox on a form. The list box is set to multiselect. I want to be able to use the selected items in a parameterized query that is predefined in access. The reason for this is that I need to run a transfertext macro that uses the query as a table. I have put the selected items from the listbox into a control on the form. The where clause looks like 'BABY FOOD' Or 'AUTOMOTIVE' if you...
|
by: asharma0001 |
last post by:
Hi all,
I was wondering whether somebody might be able to help me with a question I have on a MS Access Database I'm building.
I have created a search form with a few multiselect listboxes. What I'd ultimately like is for the selection(s) in one listbox to filter the second listbox, but am struggling to find a way to do this. I have looked at some of the other solutions on this forum but not been able to find one that works on my database....
|
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: 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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
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.
| |