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: - Private Sub Form_Load()
-
Dim rst As New ADODB.Recordset
-
-
With rst
-
With .fields
-
.Append "FullName", adLongVarChar, 260
-
.Append "Size", adInteger
-
.Append "IsFolder", adBoolean
-
End With
-
.Open
-
.fields("FullName").Properties("Optimize") = True
-
.fields("Size").Properties("Optimize") = True
-
End With
-
-
With rst
-
.AddNew
-
!FullName = "TestPath"
-
!Size = 123
-
!IsFolder = True
-
.Update
-
End With
-
-
Set Me.Recordset = rst
-
-
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
8 1902
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: - Private Sub Form_Load()
-
Dim rst As New ADODB.Recordset
-
-
With rst
-
With .fields
-
.Append "FullName", adLongVarChar, 260
-
.Append "Size", adInteger
-
.Append "IsFolder", adBoolean
-
End With
-
.Open
-
.fields("FullName").Properties("Optimize") = True
-
.fields("Size").Properties("Optimize") = True
-
End With
-
-
With rst
-
.AddNew
-
!FullName = "TestPath"
-
!Size = 123
-
!IsFolder = True
-
.Update
-
End With
-
-
Set Me.Recordset = rst
-
-
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. -
If Not IsNull("Size") And IsNumeric("Size") Then
-
.Append "Size", adInteger
-
End If
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. -
If Not IsNull("Size") And IsNumeric("Size") Then
-
.Append "Size", adInteger
-
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.
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
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.
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: -
With .fields
-
.Append "FullName", adLongVarChar, 260
-
.Append "Size", adInteger
-
.Append "IsFolder", adBoolean
-
.Update '<<<<<<<<<<<<<<<<<<<<<<<<<<
-
End With
Then I got Run-time error '445'
Object doesn't support this action
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.
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.
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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...
|
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...
|
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,...
|
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...
|
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...
|
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,...
| |