I am getting a Compile error on the following Code.
What have I missed -
Private Sub create_eplab_Click()
-
' First sort out the variables. Including label content, quantity to print etc
-
-
-
Dim var1 As String
-
Dim var2 As String
-
Dim var3 As String
-
Dim var4 As String
-
Dim var5 As String
-
-
' Sort out where the data is coming from. Aim for reusable code
-
-
Dim mydb As Database, myset As Recordset
-
Dim sql_rst As String
-
-
-
sql_rst = "SELECT * FROM qry_elabel"
-
-
Set mydb = CurrentDb
-
Set myset = mydb.OpenRecordset(sql_rst)
-
' Declare the variables values
-
-
var1 = myset![var1]
-
var2 = myset![var2]
-
var3 = myset![var3]
-
var4 = myset![var4]
-
var5 = myset![var5]
-
Const quote As String = """"
-
-
' Code each label combination required
-
-
Dim lab1 As String
-
-
lab1 = "N" & vbCrLf _
-
& "S4" & vbCrLf _
-
& "A30,30,0,5,1,1,N," & quote & [var1] & quote & vbCrLf _
-
& "A30,70,0,4,1,1,N," & quote & [var2] & quote & vbCrLf _
-
& "A30,135,0,4,1,1,N," & quote & [var3] & quote & vbCrLf _
-
& "B560,425,1,E30,1,2,160,B," & quote & [var4] & quote & vbCrLf _
-
& "A300,300,0,4,1,1,N," & quote & [var5] & quote & vbCrLf _
-
& "P1" & vbCrLf
-
-
-
' Print the label to the printer.
-
-
Open "COM2:" For Output As #1
-
Print #1, lab1
-
-
Close #1
-
-
End Sub
-
-
It debugs to the Dim mydb As Database , myset As Recordset Line.
What am I missing here?.
John S
22 7804
The qry_elabel is as below. -
-
SELECT PakTrak.PakTrakID, [Entity] & " - " & [RGN] AS var1, [VarietyDesc] & " " & [VGroup] AS var2, Sizing.SizeCode AS var3, "942001351234" AS var4, Runs.[RunCode] & "-" & [PakTrakID] AS var5
-
FROM VGroup INNER JOIN (Variety INNER JOIN (Sizing INNER JOIN ((Entity INNER JOIN Runs ON Entity.EntityID = Runs.EntityID) INNER JOIN (Packaging INNER JOIN PakTrak ON Packaging.PackageingID = PakTrak.PackageingID) ON Runs.rn_id = PakTrak.rn_id) ON Sizing.SizeID = PakTrak.SizeID) ON Variety.VarietyID = Runs.VarietyID) ON (Runs.VGroupID = VGroup.VGroupID) AND (VGroup.VGroupID = Variety.VGroupID) AND (VGroup.VGroupID = Sizing.VGroupID)
-
WHERE (((PakTrak.PakTrakID)=[Forms]![Pallet]![line_list_pal]));
-
-
Basically it sets up the text for a label, based on a selection in a listbox on the controlling form.
Any help very gratefully received.
John S
The error is
"User-defined type Not defined" and the mydb As Database is highlighted.
The Data tables are linked via ODBC, the qry_elabel consolidates data from various tables to create text strings for each variable in the label.
John S
ADezii 8,834
Recognized Expert Expert
The error is
"User-defined type Not defined" and the mydb As Database is highlighted.
The Data tables are linked via ODBC, the qry_elabel consolidates data from various tables to create text strings for each variable in the label.
John S
Make sure that the proper Type Libraries are defined in the References Dialog, e.g. Microsoft DAO 3.6 Object Library, Microsoft ActiveX Data Objects 2.X Library, etc.
Explicitly Declare the Type Libraries to which Objects belong, e.g.
Dim MyDB As DAO.Database,
Dim MyRS As DAO.Recordset,
Dim YourRS As ADODB.Recordset , etc.
Hope this helps.
NeoPa 32,569
Recognized Expert Moderator MVP
You can also use Auto-Completion.
After typing "Dim MyDB As DAO.Datab" hit Ctrl-Space. If it can find the Database object in that object it will list it. If it is not listed then you don't have the correct library (reference) listed.
Such a simple thing. Why is it selected in the development database, I certainly did not select it?.
The code now debus to the mydb.OpenRecord set(sql_rst) line. I wonder why not refer directly to mydb."qry_elabe l" as the recordset. -
-
Private Sub create_eplab_Click()
-
' First sort out the variables. Including label content, quantity to print etc
-
-
-
Dim var1 As String
-
Dim var2 As String
-
Dim var3 As String
-
Dim var4 As String
-
Dim var5 As String
-
Dim qty As Integer
-
' Sort out where the data is coming from. Aim for reusable code
-
-
Dim mydb As DAO.Database, myset As DAO.Recordset
-
Dim sql_rst As String
-
-
-
sql_rst = "SELECT * FROM qry_elabel"
-
-
-
Set mydb = CurrentDb()
-
Set myset = mydb.OpenRecordset(sql_rst)
-
-
' Declare the variables values
-
-
var1 = myset![var1]
-
var2 = myset![var2]
-
var3 = myset![var3]
-
var4 = myset![var4]
-
var5 = myset![var5]
-
Const quote As String = """"
-
-
' Code each label combination required
-
qty = Int(InputBox("How many labels for the selected line do you wish to print?", "No of Labels"))
-
Dim lab1 As String
-
-
lab1 = "N" & vbCrLf _
-
& "S4" & vbCrLf _
-
& "A30,30,0,5,1,1,N," & quote & [var1] & quote & vbCrLf _
-
& "A30,70,0,4,1,1,N," & quote & [var2] & quote & vbCrLf _
-
& "A30,135,0,4,1,1,N," & quote & [var3] & quote & vbCrLf _
-
& "B560,425,1,E30,1,2,160,B," & quote & [var4] & quote & vbCrLf _
-
& "A300,300,0,4,1,1,N," & quote & [var5] & quote & vbCrLf _
-
& "P" & quote & [qty] & quote & vbCrLf
-
-
-
' Print the label to the printer.
-
-
Open "COM2:" For Output As #1
-
Print #1, lab1
-
-
Close #1
-
-
End Sub
-
-
NeoPa 32,569
Recognized Expert Moderator MVP
Such a simple thing. Why is it selected in the development database, I certainly did not select it?
I think this means that ADezii's answer enabled the problem to be fixed.
The code now debugs to the mydb.OpenRecord set(sql_rst) line. I wonder why not refer directly to mydb."qry_elabe l" as the recordset.
That would seem to be a more straightforward way of doing it certainly.
I think this means that ADezii's answer enabled the problem to be fixed.
That would seem to be a more straightforward way of doing it certainly.
Adrian,
Would that be the more sensible way to define the recordset. As you know I do not do enough of this to be conversant, in the howto. I might have done it long ago, does not mean I know how to do it now. :-)
John S
At presant the code bombs out I think due to me not defining the data source correctly. The code at the moment. -
Private Sub create_eplab_Click()
-
' First sort out the variables. Including label content, quantity to print etc
-
-
-
Dim var1 As String
-
Dim var2 As String
-
Dim var3 As String
-
Dim var4 As String
-
Dim var5 As String
-
Dim qty As Integer
-
' Sort out where the data is coming from. Aim for reusable code
-
-
Dim mydb As Database
-
Dim myset As Recordset
-
-
Dim rst As String
-
-
-
-
rst = "SELECT * FROM [qry_elabel]"
-
-
-
-
Set mydb = CurrentDb()
-
Set myset = mydb.OpenRecordset(rst)
-
-
' Declare the variable data values
-
-
var1 = myset![v1]
-
var2 = myset![v2]
-
var3 = myset![v3]
-
var4 = myset![v4]
-
var5 = myset![v5]
-
-
Const quote As String = """"
-
-
' Code each label combination required
-
qty = Int(InputBox("How many labels for the selected line do you wish to print?", "No of Labels"))
-
Dim lab1 As String
-
-
lab1 = "N" & vbCrLf _
-
& "S4" & vbCrLf _
-
& "A30,30,0,5,1,1,N," & quote & [var1] & quote & vbCrLf _
-
& "A30,70,0,4,1,1,N," & quote & [var2] & quote & vbCrLf _
-
& "A30,135,0,4,1,1,N," & quote & [var3] & quote & vbCrLf _
-
& "B560,425,1,E30,1,2,160,B," & quote & [var4] & quote & vbCrLf _
-
& "A300,300,0,4,1,1,N," & quote & [var5] & quote & vbCrLf _
-
& "P" & quote & [qty] & quote & vbCrLf
-
-
-
' Print the label to the printer.
-
-
Open "COM2:" For Output As #1
-
Print #1, lab1
-
-
Close #1
-
-
End Sub
-
-
"qry_elabel " is a query that consolidates various fields from multiple tables into 5 variables for the label. v1,v2,v3,v4,v5 the tables are linked tables from another Access Database, that just has tables in it. Can someone patiently explain where I am going wrong. It Halts at the myset = mydb.OpenRecord set(rst), with A Not enough operators in statement message. (I assume the sql SELECT statement).
Not much chop without data :-)
John S
MMcCarthy 14,534
Recognized Expert Moderator MVP
John
Just try ... -
-
Dim mydb As Database
-
Dim myset As DAO.Recordset ' Just a precaution
-
-
Set mydb = CurrentDb()
-
Set myset = mydb.OpenRecordset("qry_elabel")
-
-
Mary
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Xiaofeng Zhang |
last post by:
when I compile my project setting, there are many LINK
errors. But when I compile my project under debug setting,
everything is OK. How can I deal with it?
The errors is followed.
Linking...
LIBCMT.lib(crt0dat.obj) : error LNK2005: _exit already
defined in msvcrt.lib(MSVCR71.dll)
LIBCMT.lib(crt0dat.obj) : error LNK2005: __exit already
defined in msvcrt.lib(MSVCR71.dll)
|
by: newbiecpp |
last post by:
I have hard time to understand run-time environment. Let assume that I have
a program that has a simple variable alpha. When this variable is
statically allocated, the compiler can use the absolute address of alpha to
access to it. What confuses me is that when the variable is dynamically
allocated, how does the compiler implement it? We know the address of the
variable until run-time. During the compilation, how can we access to the...
|
by: Jean-David Beyer |
last post by:
I have some programs running on Red Hat Linux 7.3 working with IBM DB2
V6.1 (with all the FixPacks) on my old machine.
I have just installed IBM DB2 V8.1 on this (new) machine running Red Hat
Enterplise Linux 3 ES, and applied FixPack fp5_mi00069.tar to it. After
creating an instance, starting the database, creating a database, and
entering the table definitions, all of which seems to work OK, I entered a
tiny 8-row table and can do...
|
by: Monte |
last post by:
It compiles fine in one of my ms2002 databases, but on another db (I
inherited from somebody else), I get this compile error: "User-defined type
not defined"
Is something turned off in this second db or something? Thanks much
|
by: Peter Frost |
last post by:
Please help
I don't know if this is possible but what I would really like to do is
to use On Error Goto to capture the code that is being executed when
an error occurs.
Any help would be much appreciated.
Thanks in advance
| |
by: mastermagrath |
last post by:
Hi,
I'm about half way through Bruce Eckels thinking in C++ Vol 1. He gives
a very short example of how compiler function name decoration helps
remove subtle bugs by type-safe linkage. However, upon looking at the
example i understand why it fails to link but don't understand why it
even compiles. Here's the code, which split between 2 files Def.cpp and
Use.cpp:
//File Def.cpp
|
by: B Williams |
last post by:
I have been working with this code for a better part of the day and I can't
figure out where I am making a mistake. I can only imagine it is when I
declare multiple paramaters on the constructor because the program compiles
with just one parameter. Can someone look at this and tell me where I made
my error?
This is the error I get while trying to compile.
error C2664: 'GradeBook::GradeBook(const GradeBook &)' : cannot convert...
|
by: john |
last post by:
I'm trying to use the code below. But when the code is run I get:
Compile error: an infotype defined by user is not defined. <dbClient As
Databaseis then highlighted.
Somebody an idea on how do I make this work?
Thanks,
john
Private Sub CheckExists(strTableName As String)
' check to see if the table exists, if it does then delete it since the next
|
by: blakerrr |
last post by:
Hi everyone,
I am trying to export a table to an excel file using vba on a form's button click event. I am getting the error:
Compile error: User-defined type not defined.
And it highlights my first line:
Dim appExcel As Excel.Application
Any ideas? I am using Access 2003, but I am using Access 2000 file format. Does this have to with DAO and ADO something-or-others? I'm a beginner with all of this database stuff so please...
|
by: Tim H |
last post by:
The following program compiles just fine in C, but not in C++. Can
anyone explain why? I have a chunk of code that defines stuff like
this in headers (without the extern) that I can not easily change.
The C compiler recognizes the first foo and second foo as the same.
The C++ compiler not so much.
Is there a way to get this to compile in C++ without changing all the
headers?
|
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: 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: 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
| |