473,396 Members | 2,158 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Values shown only in string fields of forms with fabricated ADO recordset

5
I faced with problem in the subject.

I need to dinamicaly create the recordset and show the results in a small subform.
To construct and test the form I made following test code for form load event:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.     Dim rst As New ADODB.Recordset
  3.  
  4.     With rst
  5.         With .fields
  6.             .Append "FullName", adLongVarChar, 260
  7.             .Append "Size", adInteger
  8.             .Append "IsFolder", adBoolean
  9.         End With
  10.         .Open
  11.         .fields("FullName").Properties("Optimize") = True
  12.         .fields("Size").Properties("Optimize") = True
  13.     End With
  14.  
  15.     With rst
  16.         .AddNew
  17.         !FullName = "TestPath"
  18.         !Size = 123
  19.         !IsFolder = True
  20.         .Update
  21.     End With
  22.  
  23.    Set Me.Recordset = rst
  24.  
  25. End Sub
And then I designed the text line controls with the field names above in Control Sources. Then when showing form I can see values only in text fields, while in other fields/textline controls there are #Error.

It is Access2003
What could be wrong?

Thanks in adwance,
Janeks
Jan 4 '08 #1
8 1902
puppydogbuddy
1,923 Expert 1GB
I faced with problem in the subject.

I need to dinamicaly create the recordset and show the results in a small subform.
To construct and test the form I made following test code for form load event:

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2.     Dim rst As New ADODB.Recordset
  3.  
  4.     With rst
  5.         With .fields
  6.             .Append "FullName", adLongVarChar, 260
  7.             .Append "Size", adInteger
  8.             .Append "IsFolder", adBoolean
  9.         End With
  10.         .Open
  11.         .fields("FullName").Properties("Optimize") = True
  12.         .fields("Size").Properties("Optimize") = True
  13.     End With
  14.  
  15.     With rst
  16.         .AddNew
  17.         !FullName = "TestPath"
  18.         !Size = 123
  19.         !IsFolder = True
  20.         .Update
  21.     End With
  22.  
  23.    Set Me.Recordset = rst
  24.  
  25. End Sub
And then I designed the text line controls with the field names above in Control Sources. Then when showing form I can see values only in text fields, while in other fields/textline controls there are #Error.

It is Access2003
What could be wrong?

Thanks in adwance,
Janeks
I am not sure, but it looks like you are encountering nulls or non-numeric values when you are adding/appending values for the size field. Try testing for nulls or non-numeric values before doing the add/append.
Expand|Select|Wrap|Line Numbers
  1. If Not IsNull("Size") And IsNumeric("Size") Then
  2.         .Append "Size", adInteger
  3. End If
Jan 5 '08 #2
janeks
5
I am not sure, but it looks like you are encountering nulls or non-numeric values when you are adding/appending values for the size field. Try testing for nulls or non-numeric values before doing the add/append.
Expand|Select|Wrap|Line Numbers
  1. If Not IsNull("Size") And IsNumeric("Size") Then
  2.         .Append "Size", adInteger
  3. End If
It should be not a problem.
When I am testing what I appended by using Debug.Print or MsgBox, then all works fine.
Interesting behaviour I observer when I clicked in check box of boolean field, than the value in size field suddenly appears in place of #Error.
Jan 5 '08 #3
puppydogbuddy
1,923 Expert 1GB
It should be not a problem.
When I am testing what I appended by using Debug.Print or MsgBox, then all works fine.
Interesting behaviour I observer when I clicked in check box of boolean field, than the value in size field suddenly appears in place of #Error.
Ok, if it is the yes/no (boolean) fields, there is a known bug that results in an error if the boolean field is null. This link contains the work-around for the problem.

http://allenbrowne.com/bug-14.html
Jan 5 '08 #4
janeks
5
Ok, if it is the yes/no (boolean) fields, there is a known bug that results in an error if the boolean field is null. This link contains the work-around for the problem.

http://allenbrowne.com/bug-14.html
That is not only yes/no (boolean) fields (the same problem persists with f.ex. numeric fields if there is no boolean field) and the case in link was about query, but in this case it in code created recordset.
Jan 5 '08 #5
puppydogbuddy
1,923 Expert 1GB
That is not only yes/no (boolean) fields (the same problem persists with f.ex. numeric fields if there is no boolean field) and the case in link was about query, but in this case it in code created recordset.
In your prior response, you said everything was working ok, except for the boolean fields. Based on your new statement above, I looked at your code again and it appears to me that you left out the .Update command on your append code as shown below:
Expand|Select|Wrap|Line Numbers
  1. With .fields
  2.             .Append "FullName", adLongVarChar, 260
  3.             .Append "Size", adInteger
  4.             .Append "IsFolder", adBoolean
  5.             .Update   '<<<<<<<<<<<<<<<<<<<<<<<<<<
  6. End With
Jan 5 '08 #6
janeks
5
Then I got Run-time error '445'

Object doesn't support this action
Jan 5 '08 #7
puppydogbuddy
1,923 Expert 1GB
Then I got Run-time error '445'

Object doesn't support this action
Your first append line is appending a fields collection object and a value to a recordset object. You need to create the field object before the recordset object is opened, then append the value to the newly created fields object.

See this link:

http://msdn2.microsoft.com/en-us/lib...64(VS.85).aspx


Excerpt from the link:
The FieldValue parameter is only valid when adding a Field object to a Record object, not to a Recordset object. With a Record object, you can append fields and provide values at the same time. With a Recordset object, you must create fields while the Recordset is closed, and then open the Recordset and assign values to the fields.
Jan 5 '08 #8
janeks
5
Isn't so in my 1-st code example?

Up to line 10 the fields are appended,
Then in line 10 the recordset is opened and only then the field values are added from line 16.
Jan 5 '08 #9

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

Similar topics

1
by: Joseph Del Medico | last post by:
I'm trying to use a query whose SQL view is shown below to get a recordset of all first quarter records from a table for a year that is in the textbox of a form, so I can sum up the totals for the...
8
by: Chris A via AccessMonster.com | last post by:
I have an interesting problem that I have yet to come accross that I can't change data structure on because it is an export from filemaker I am reformatting for another dept. anyway. I have a table...
5
by: Bubba | last post by:
I have a dynamic pulldown list (ASP with javascript) that when a user picks a state, the corresponding counties for that state appear in a dynamic second pulldown list. When I submit the form, the...
8
by: KelvinA | last post by:
I'm constructing a SQL statement called strTxSQL that is supposed to use two variables: lngItemCode (long integer) and datMyDate (date defined as MM/DD/YYYY). The SQL statement will not work with...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
marktang
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,...
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
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...
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,...

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.