473,659 Members | 2,671 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

<<HELP>> Problem with recalling a record and displaying it on the form!

I am trying to retrive one field from the "company info" table that
contains several fields but I want the "company name" field. There is
only one record in this table. When I entered the code below (which I
copied out of a book). I get the following error. The hickup comes in
the "dim db as database" line. However if I comment this out. It
doesn't like the next line either.

I appreciate any help you can give me. Also is this a problem between
ADO and DAO?

Error I receive is:

Microsoft Visual Basic
! Compile Error:
User-defined type not defined

Private Sub Form_Load()

Dim db as database
Dim rst as recordset
Dim strsql as string
Dim coname as string

Set db = currentdb
strsql = "select [company name] from [company info]"
set rst=db.openreco rdset(strsql)
rst.movelast
rst.movefirst
coname=rst!("co mpany name")
me.txtcompanyna me = coname
rst.close
Set rst = nothing
Set db = nothing

End Sub

Thanks for all your help in advance!

Chuck
Nov 12 '05 #1
2 1894

"Chuck" <w0***@yahoo.co m> wrote in message
news:64******** *************** ***@posting.goo gle.com...
I am trying to retrive one field from the "company info" table that
contains several fields but I want the "company name" field. There is
only one record in this table. When I entered the code below (which I
copied out of a book). I get the following error. The hickup comes in
the "dim db as database" line. However if I comment this out. It
doesn't like the next line either.

I appreciate any help you can give me. Also is this a problem between
ADO and DAO?
Almost certainly. This code is DAO. You very likely don't have a reference
to DAO set. Go to Tools->References to set it. Personally, I don't like to
mix DAO and ADO code in the same project, I would also uncheck the reference
to ADO.

Randy
Error I receive is:

Microsoft Visual Basic
! Compile Error:
User-defined type not defined

Private Sub Form_Load()

Dim db as database
Dim rst as recordset
Dim strsql as string
Dim coname as string

Set db = currentdb
strsql = "select [company name] from [company info]"
set rst=db.openreco rdset(strsql)
rst.movelast
rst.movefirst
coname=rst!("co mpany name")
me.txtcompanyna me = coname
rst.close
Set rst = nothing
Set db = nothing

End Sub

Thanks for all your help in advance!

Chuck

Nov 12 '05 #2
"Randy Harris" <ra***@SpamFree .com> wrote in message news:<YP******* ************@ne wssvr16.news.pr odigy.com>...
"Chuck" <w0***@yahoo.co m> wrote in message
news:64******** *************** ***@posting.goo gle.com...
I am trying to retrive one field from the "company info" table that
contains several fields but I want the "company name" field. There is
only one record in this table. When I entered the code below (which I
copied out of a book). I get the following error. The hickup comes in
the "dim db as database" line. However if I comment this out. It
doesn't like the next line either.

I appreciate any help you can give me. Also is this a problem between
ADO and DAO?


Almost certainly. This code is DAO. You very likely don't have a reference
to DAO set. Go to Tools->References to set it. Personally, I don't like to
mix DAO and ADO code in the same project, I would also uncheck the reference
to ADO.

Randy
Error I receive is:

Microsoft Visual Basic
! Compile Error:
User-defined type not defined

Private Sub Form_Load()

Dim db as database
Dim rst as recordset
Dim strsql as string
Dim coname as string

Set db = currentdb
strsql = "select [company name] from [company info]"
set rst=db.openreco rdset(strsql)
rst.movelast
rst.movefirst
coname=rst!("co mpany name")
me.txtcompanyna me = coname
rst.close
Set rst = nothing
Set db = nothing

End Sub

Thanks for all your help in advance!

Chuck


Thanks Randy,

This seems to have cleared up alot. I guess from the DAO version you
can't use the "me." reference for the open form?

Thanks Again,
Chuck
Nov 12 '05 #3

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

Similar topics

31
14328
by: da Vinci | last post by:
OK, this has got to be a simple one and yet I cannot find the answer in my textbook. How can I get a simple pause after an output line, that simply waits for any key to be pressed to move on? Basically: "Press any key to continue..." I beleive that I am looking for is something along the lines of a....
4
1688
by: Chuck | last post by:
Hello, I have an Access XP database that has several fields. One of the fields is a text field and has an account number that is preceeded by a text character, like: F102354. Every account number has this prefix and is always followed by a 6 digit number. What I need to do is to drop the character at the beginning and keep the remaining part of the account number.
1
1549
by: Chuck | last post by:
I have a question tht I'm sure someone out there can answer. A friend of mine has developed an Access application that is a very business specific (niche type of application). The application would only be used by one type of business but there are a lot of these businesses out there along without too much competition. He is interested in selling the application (a runtime version of Access would be supplied as well) but he works...
1
719
by: Chuck | last post by:
I have a query that uses the query with the critera set to . We I run the query the msgbox pops up asking for the name information to be entered, but on the top (blue background) of the message box it says" Enter Parameter Value ". Is there anyway to change this to something that is not as generic. I appreciate any help you can give. Thanks Chuck
2
309
by: Chuck | last post by:
I am trying to retrive one field from the "company info" table that contains several fields but I want the "company name" field. There is only one record in this table. When I entered the code below (which I copied out of a book). I get the following error. The hickup comes in the "dim db as database" line. However if I comment this out. It doesn't like the next line either. I appreciate any help you can give me. Also is this a problem...
1
2947
by: Chuck | last post by:
I appreciate any help!!! I have an application that has 4 different forms that display the same information except for the fact that they are fed from 4 different parameter queries. The 4 different forms are activated by 4 different buttons on the main switchboard. Of course, this makes me change 4 different forms when I make a change to any of them. Is there anyway to open one form from different queries when different buttons are...
1
1485
by: WØCBF | last post by:
I have an Access application that was written in ver 2002. I have distributed the application to our other offices using the Developers Toolkit and installed a runtime version of Access. At that time no other versions of Access was on their computer systems. Now, if Access 2003 (full version) is installed on each machine what will this cause to the run time version of Access as well as the application. Is their anyway to control the...
3
2073
by: WØCBF | last post by:
I know this code has worked before but now appears to get a compile error. The code it seems to choke on line 12. I receive the following message and it highlights the "rst!" statement. Error received: Microsoft Visual Basic Compile error: Type declaration character does not match declared data type Private Sub Form_Load() 1 Dim db As Database
1
1562
by: WØCBF | last post by:
Greetings, I have a form that is bound to a table that has about 15 fields in it and all of the fields are displayed on the main form. I have 4 fields that will be updated and I want to write that information to another table that only has only these 4 fields in it. Since the form is bound to one table, how can I write these 4 fields to a different table. These fields will be written when on on click event occurs on a button. Any help...
2
1838
by: WØCBF | last post by:
I am trying to copy the information from a form into a table. I have tried running the sql code from a macro by using the command : This works and writes the work 'test' into the field name 'name' in the 'temptable' table: insert into temptable (name) values (test) But I don't know the correct syntax for writing the field on the form into the test table. I tried (with no luck) to use this code:
0
8330
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,...
0
8850
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, 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...
1
8523
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,...
0
8626
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7355
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6178
isladogs
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...
0
4334
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2749
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
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.