473,503 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Invalid Use Of Property Problem

72 New Member
hin there i hope someone can tell what i been doing wrong with my program, my program is this i want to display all my database records in a text box e.i text3(0) to (15), it seems the connection doesnt have any problem. but whenever i run my program an error pop up to indicating "INVALID USE OF PROPERTY" what is this..

This is my code:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub Command1_Click()
  3. Dim rs As New ADODB.Recordset
  4. Dim cnn As New ADODB.Connection
  5. Dim x As Integer
  6. Dim strsql As String
  7. Dim strconn As String
  8.  
  9. 'Database Connection__________________________________________________
  10. Set cnn = New ADODB.Connection
  11. cnn.ConnectionString = _
  12.  "Provider=Microsoft.Jet.OLEDB.3.51;" & _
  13.           "Data Source=" & App.Path & "\dbTimeScheduling2.mdb;"
  14. cnn.Open strconn
  15. 'Database Connection____________________________________________________
  16.  
  17. 'Subject Codes
  18.  
  19.  strsqql = "SELECT * from SUBJECTS WHERE Primary ID 'ABA0101**'"
  20.  Set rs = New ADODB.Recordset
  21.  rs.MaxRecords = 1
  22.  rs.Open strsql, conn, adOpenDynamic, adLockOptimistic
  23.  
  24.     While rs.EOF <> True
  25.         For x = 0 To 15 Step 1
  26.             Text3(x).Text rs.Fields("SUBJECT CODES").Value
  27.  
  28.          rs.MoveNext
  29.         Next x
  30.     Wend
  31.  
  32. End Sub
  33.  
  34.  
I hope some body can figure out what is wrong with my program. Thank you very much...
May 11 '07 #1
12 9493
Killer42
8,435 Recognized Expert Expert
I'm not sure whether it's the cause of your problem, but I believe I can see at least two places where you've left out an equals sign. Unless there's something wrong with the way the code was copied into your post, I suppose.

You didn't tell us exactly where the problem is reported, or what version of VB you're using. Though judging by the control array, I'd say VB6. Anyway, these are the two lines which immediately caught my attention, each followed by what I think they should look like...
Expand|Select|Wrap|Line Numbers
  1. SELECT * from SUBJECTS WHERE Primary ID 'ABA0101**'
  2. SELECT * from SUBJECTS WHERE PrimaryI= 'ABA0101**'
  3.  
  4. Text3(x).Text rs.Fields("SUBJECT CODES").Value
  5. Text3(x).Text = rs.Fields("SUBJECT CODES").Value
(Note the underline showing where I also removed a space.)

One more thing - are those asterisks actually part of the value, or are they supposed to represent a wildcard - that is, a position where you don't know the exact characters?
May 11 '07 #2
Tig201
103 New Member
Just thought I’d mention that if your table or field names contain spaces you need to enclose them in bracket
Expand|Select|Wrap|Line Numbers
  1. SELECT * from SUBJECTS WHERE [Primary ID] = 'ABA0101**'
May 11 '07 #3
darrel
72 New Member
Thank you for entertaining my question am getting the error in this area of my code:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Text3(x).Text rs.Field ("SUBJECT CODES").Value
  3.  
  4.  
To be specific the ".Text" area is the highlighted one.
I'am going to try the one you have said..

Ill keep you posted..

Again Thank you..
May 12 '07 #4
darrel
72 New Member
Mr. Killer ive tried all what have you said but it doesnt change anything, i still recieve th INAVALID USE OF PROPERTY...

I dont know y???

Can you help me with, i figured out the my code that i dont have the word "LIKE" ive tried it, but it doesnt change anything..


Hope you can figure out the problem. Thank you in advance.
May 12 '07 #5
danp129
323 Recognized Expert Contributor
Repost your current code, note the line you're having trouble executing again, and a sample record that is in your database that you would expect to have been found by your SQL query.
May 12 '07 #6
danp129
323 Recognized Expert Contributor
Quote
Hi there, good day! i need some help in displaying my records,,, my assignment is i have to display a database records in a labels.
Disregard my last post, I didn't realize this was homework.
May 12 '07 #7
Killer42
8,435 Recognized Expert Expert
Ok, I think we need to clarify exactly what is going on, rather than just relying on what it looks like.
  • Is this VB6?
  • Is Text3 an array of TextBox controls?
  • Which time around the loop does the error occur? Or, to put it another way, what is the value of x?
  • Is this line copied exactly as it was in your code?
    Text3(x).Text rs.Field ("SUBJECT CODES").Value
    Because as far as I can tell, it doesn't mean anything. It simply lists a control property and a database field, without saying what to do with them. I'm sure there should be an assignment (=) between them.
  • A fundamental rule of debugging - simplify!
    Is it the textbox or the database field which is causing the problem? It sounds like the textbox, so get rid of the database field until you've made sure. Copy the line, comment out the original, and change the new one to something like
    Text3(x).Text = "A"
    Then see what happens at that point.
  • If you haven't already, learn to use the debugging facilities provded by the IDE (Integrated Development Environment, I think that is). These allow you to interrupt the code, step through it one statement at a time, examine and change variable values on the fly, etc.
  • Is this a homework/classwork assignment?
    (Dan, don't worry about it. We're happy to help people to debug and understand their code for homework assignments, as long as they are making a real effort to do the work themselves. The problem is when people just paste assignment questions here and expect us to answer them.)
May 12 '07 #8
danp129
323 Recognized Expert Contributor
Yes but most (but not all) of the time I don't have the patience to be a teacher and teach best concepts and practices. I don't mean to push him away but the question I asked was relevant to what I wanted to know to help, and after figuring out it was homework, I didn't want him to post what I asked him for and then not continue to help.

I like to help out and your post above was great help for a student because he can learn from it, you didn't just fix the problem. But I don't have *that* much patience.
May 12 '07 #9
darrel
72 New Member
Yes my program is in VB6.
Yes! Text3(x).Text is a control array.
Yes! its a database field, and that is my problem.
It is a work project not a class home work.
May 12 '07 #10
Killer42
8,435 Recognized Expert Expert
Yes but most (but not all) of the time I don't have the patience to be a teacher and teach best concepts and practices. I don't mean to push him away but the question I asked was relevant to what I wanted to know to help, and after figuring out it was homework, I didn't want him to post what I asked him for and then not continue to help.

I like to help out and your post above was great help for a student because he can learn from it, you didn't just fix the problem. But I don't have *that* much patience.
Fair enough. I just thought you were concerned about the site's homework policy or something.

I've got patience "in spades". :)
May 12 '07 #11
danp129
323 Recognized Expert Contributor
Well I did also have a slight thought of it being against policy too if it matters :P

Darrel
Anyhow I had thought that if you wanted to use a wildcard through ODBC to access you had to use %, and that the * only worked inside of access... I can't remember and it's getting to late for me to test it (which I was going to earlier) but that's the reason I wanted a sample record to know what you was trying to match. I also wanted the current code cause I don't know what all you tried from previous people's posts. I'm sorry I assumed it was for school but it appeared to be.
May 12 '07 #12
Expand|Select|Wrap|Line Numbers
  1. Private Sub Command1_Click()
  2.     Label2.Visible
  3. End Sub
  4.  
this shows invalid use of property when the button is clicked
Oct 6 '10 #13

Sign in to post your reply or Sign up for a free account.

Similar topics

1
10114
by: David Gerstman | last post by:
I have the following code in a mult-form project: Private Sub Form_Load() sldPackets.Min = frmStartBfv.return_first() sldPackets.Max = frmStartBfv.return_last() End Sub I wish to connect the...
3
2991
by: Stephen Poley | last post by:
Could some kind soul explain the errors and warnings that the W3C CSS validator generates for page: http://www.atlis.nl/testsite/nl/ Results at: http://tinyurl.com/5pxqx The error "Invalid...
0
1007
by: John Hunter | last post by:
I've recently had a nasty problem with the "Invalid reference to the property Form" error in subforms - nasty because it doesn't seem to consistently happen to all forms which contain the same...
2
4239
by: Nicolas LeBlanc | last post by:
I've seen several message on newsgroup, but none helped me fixed this damned problem. I am not on a load balancing, and the copy in the server is there for ages, and yet I receive 10 to 20 times...
3
2710
by: Twanger | last post by:
I'm getting a compiler error on my ASP.NET page and I can't see the cause. I have a simple C# class compiled into a DLL and placed in my bin directory which has a public property QuestionText. ...
1
2762
by: alex | last post by:
Hi, when building a new project i get the following errors Invalid language characters in property 'Depenendencies' Invalid language characters in property 'Files' It all points to...
2
5716
by: Schorschi | last post by:
Can't seemd to get ReadFile API to work! Returns invalid handle error? =========================================================================== Ok, the visual basic gurus, help! The...
10
2748
by: Chet Cromer | last post by:
I am creating a set of base classes and sub classes to use throughout a program I'm developing. The base class represents a generic "lookup table" from my database that contains lists of things...
5
6849
by: jason.neo | last post by:
Hi all experts, I am going nuts with this Invalid postback or callback argument thingy with .Net 2.0 I am building a file attachment module which relays on a Datatable stored in session (yeah...
1
2791
by: eBob.com | last post by:
I have some code which is trying to determine where text will wrap in a custom text box (which Inherits from Control). It determines the number of characters which will fit in the first line, but...
0
7086
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
7280
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
7330
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...
0
7460
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...
1
5014
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...
0
4672
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...
0
3167
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...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
380
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...

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.