473,467 Members | 1,419 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

<<help>> Code worked before and now it doesn't!

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 [(OK) (HELP)]

Private Sub Form_Load()

1 Dim db As Database
2 Dim rst As Recordset
3 Dim strsql As String
4 Dim idnumber As long
5 Dim firstname As String
6 Dim Lastmane As String

7 Set db = CurrentDb
8 strsql = "select [idnumber] from [workers]"
9 Set rst = db.OpenRecordset(strsql)
10 rst.MoveLast
11 rst.MoveFirst
12 idnumber = rst!("idnumber")
13 me.switchboardform = idnumber
14 rst.Close
15 Set rst = Nothing
16 Set db = Nothing

End Sub

Any ideas would be appreciated.
Thanks
Chuck

Nov 13 '05 #1
3 2063
WØCBF wrote:
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 [(OK) (HELP)]

Private Sub Form_Load()

1 Dim db As Database
2 Dim rst As Recordset
3 Dim strsql As String
4 Dim idnumber As long
5 Dim firstname As String
6 Dim Lastmane As String

7 Set db = CurrentDb
8 strsql = "select [idnumber] from [workers]"
9 Set rst = db.OpenRecordset(strsql)
10 rst.MoveLast
11 rst.MoveFirst
12 idnumber = rst!("idnumber")
13 me.switchboardform = idnumber
14 rst.Close
15 Set rst = Nothing
16 Set db = Nothing

End Sub

Any ideas would be appreciated.
Thanks
Chuck

Go look at the type definition for idnumber in table workers. I will
bet it is not the same as idnumber, the variable, defined as long.

Bob
Nov 13 '05 #2
Try

idnumber = rst!idnumber

or

idnumber = rst.Fields("idnumber")


--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"WØCBF" <w0***@yahoo.com> wrote in message
news:11**********************@g44g2000cwa.googlegr oups.com...
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 [(OK) (HELP)]

Private Sub Form_Load()

1 Dim db As Database
2 Dim rst As Recordset
3 Dim strsql As String
4 Dim idnumber As long
5 Dim firstname As String
6 Dim Lastmane As String

7 Set db = CurrentDb
8 strsql = "select [idnumber] from [workers]"
9 Set rst = db.OpenRecordset(strsql)
10 rst.MoveLast
11 rst.MoveFirst
12 idnumber = rst!("idnumber")
13 me.switchboardform = idnumber
14 rst.Close
15 Set rst = Nothing
16 Set db = Nothing

End Sub

Any ideas would be appreciated.
Thanks
Chuck

Nov 13 '05 #3
WØCBF wrote:
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 [(OK) (HELP)]

Private Sub Form_Load()

1 Dim db As Database
2 Dim rst As Recordset
3 Dim strsql As String
4 Dim idnumber As long
5 Dim firstname As String
6 Dim Lastmane As String

7 Set db = CurrentDb
8 strsql = "select [idnumber] from [workers]"
9 Set rst = db.OpenRecordset(strsql)
10 rst.MoveLast
11 rst.MoveFirst
12 idnumber = rst!("idnumber")
13 me.switchboardform = idnumber
14 rst.Close
15 Set rst = Nothing
16 Set db = Nothing

End Sub

Any ideas would be appreciated.
Thanks
Chuck

See the comment from RDWaibel

http://www.experts-exchange.com/Data..._21207636.html

" the problem, as I see it, is the ! that you have after the Rst. To
use the name of the field as teh identifier, you don't need the !. Like
so....

rst(fldName$)"
In my code I personally use the following syntax:

INrec.Fields(fldName$)
Nov 13 '05 #4

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

Similar topics

31
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? ...
4
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...
1
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...
2
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...
1
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...
1
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...
2
by: V e X y N | last post by:
OK, here's the deal, if anyone could help me with a link or two, I'd be delighted. I'm just learning C (I learned over the summer, so a few months), and I was wondering what (*free*) compilers are...
1
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...
2
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...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
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...
0
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,...
0
jinu1996
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...
1
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...
0
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,...
0
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...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.