473,418 Members | 2,055 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,418 software developers and data experts.

Reading all values from datasheet subform

8
I have a mail form that has a datasheet subform, there can be up to sixty items in the datasheet. The data sheet has three fields: AttID, AttName, AttYN

The object is for the enduser to select attributes, that relate to the contact on the main form.
Below is the code I have been working with to read all the attributes checked "Yes". The intent is then update/append the cntID from the main form, the attID and attYN value into a linked table. (Second part of this module)

The initial issues are:
1) When using an IF statement the only recongizable value in the subform
is "-1".The following are not recognized by the IF statment: "0","<> -1", Null, or <> Null. What I am after is to select all attYN <> -1
2) When running the debug.print for the values, as the shortened loop runs, the value for the CategoryID stays the same, but the counter increments

The code is:
Private Sub Command4_Click()
Dim aconID, aattID, asel, cnter

For cnter = 0 To 6
If (Forms!ztestatt2!zsfrmattrib.Form!consel.Value = -1) Then
aattID = Forms!ztestatt2!zsfrmattrib.Form!categoryID.Value
asel = Forms!ztestatt2!zsfrmattrib.Form!consel.Value

Debug.Print cnter, Me.CntID, aattID, asel

End If

The results in the debug.print is
0 2 1 -1
1 2 1 -1
2 2 1 -1
3 2 1 -1
4 2 1 -1
5 2 1 -1
6 2 1 -1

It looks as if the cnter is incrementing but I am not incrementing through the datasheet. The values are only for the first record.
Looks like the next question is how do I increment through the datasheet?



Note: The Me.CntID is from the main form for this contact
Sep 3 '07 #1
4 4917
paulw4
8
OK, I have been researching the record set clone and movenext features and have the following code

Set frm1 = Forms("ztestatt2")
Set ctl1 = frm1.zsfrmattrib

Debug.Print frm1.RecordSource
Debug.Print ctl1.Form.RecordSource
Debug.Print ctl1.Form.RecordsetClone.RecordCount
Debug.Print

For int2 = 0 To ctl1.Form.RecordsetClone.RecordCount - 1


Debug.Print int2, ctl1.Controls!CategoryID _
, ctl1.Controls!Category _
& " " & ctl1.Controls!consel
' ctl1.Form.RecordsetClone.MoveNext

Next int2

The results are:
qryContacts (RECORD SOURCE FOR MAIN FORM)
qryconattrib (RECORD SOURCE FOR SUBFORM)
54 (RECORD COUNT)

0 59 Colleges and Universities 0
1 59 Colleges and Universities 0
2 59 Colleges and Universities 0
.
.
.
51 59 Colleges and Universities 0
52 59 Colleges and Universities 0
53 59 Colleges and Universities 0


Many thing about this have me baffled
1. How do I get it to start at 0 record for the loop
2. Why is the last record the record that is being read

Thanks for the help!
PW
Sep 3 '07 #2
FishVal
2,653 Expert 2GB
OK, I have been researching the record set clone and movenext features and have the following code

Set frm1 = Forms("ztestatt2")
Set ctl1 = frm1.zsfrmattrib

Debug.Print frm1.RecordSource
Debug.Print ctl1.Form.RecordSource
Debug.Print ctl1.Form.RecordsetClone.RecordCount
Debug.Print

For int2 = 0 To ctl1.Form.RecordsetClone.RecordCount - 1


Debug.Print int2, ctl1.Controls!CategoryID _
, ctl1.Controls!Category _
& " " & ctl1.Controls!consel
' ctl1.Form.RecordsetClone.MoveNext

Next int2

The results are:
qryContacts (RECORD SOURCE FOR MAIN FORM)
qryconattrib (RECORD SOURCE FOR SUBFORM)
54 (RECORD COUNT)

0 59 Colleges and Universities 0
1 59 Colleges and Universities 0
2 59 Colleges and Universities 0
.
.
.
51 59 Colleges and Universities 0
52 59 Colleges and Universities 0
53 59 Colleges and Universities 0


Many thing about this have me baffled
1. How do I get it to start at 0 record for the loop
2. Why is the last record the record that is being read

Thanks for the help!
PW
Hi, there.

Try this.

Expand|Select|Wrap|Line Numbers
  1. ................
  2. Dim RS as DAO.Recordset
  3. .............................
  4. Set RS = ctl1.Form.RecordsetClone
  5.  
  6. With RS
  7.     .MoveFirst
  8.     While Not .EOF
  9.         Debug.Print ![Field1Name];" "; ![Field2Name] ...............
  10.     Wend
  11. End With
  12. ................
  13. Set RS = Nothing
  14.  
Sep 4 '07 #3
paulw4
8
Thanks for all the help to date.
I thought the next step would be easy.....

After reading the datasheet, the next event is to append AND/OR update a table with all the values, even for the False results.
Can someone help with the structure of the correct process...

Thanks
PW
Sep 5 '07 #4
FishVal
2,653 Expert 2GB
Thanks for all the help to date.
I thought the next step would be easy.....

After reading the datasheet, the next event is to append AND/OR update a table with all the values, even for the False results.
Can someone help with the structure of the correct process...

Thanks
PW
Hi, PW.

Please include the MetaData for main form and subform RecordSource and Master/Child link fields, as well as MetaData of the table you want to append to.


Here is an example of how to post table MetaData :
Table Name=tblStudent
Expand|Select|Wrap|Line Numbers
  1. Field; Type; IndexInfo
  2. StudentID; AutoNumber; PK
  3. Family; String; FK
  4. Name; String
  5. University; String; FK
  6. Mark; Numeric
  7. LastAttendance; Date/Time
Sep 5 '07 #5

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

Similar topics

2
by: ivan | last post by:
I have a form (CustomerImfo) that has a subform within it (order). Within that subform is another subform (OrderDetail). That subform (OrderDetail) is displayed in Datasheet view. When I am...
1
by: Richard Sherratt | last post by:
I added a new field to a table in the tables database. In the code database, I added a new column for the new field to a datasheet subform. I opened it in datasheet view and moved the column to the...
5
by: kotowskil | last post by:
A report has a subform. The subform is set to datasheet view and its RecordSource is a select query that includes a memo field from the source table. The memo field's Can Grow property is Yes,...
7
by: Ken Mylar | last post by:
First a quick background on the form: I have a form that is normally viewed in Single form mode. It has a subform on it that is in datasheet view. The main form is for work orders and the...
1
by: planetthoughtful | last post by:
Hi All, I have a mainform with a subform in which I show some task summary data. On the mainform I have a number of unbound controls that reflect values relevant to each task in the subform....
2
by: fstenoughsnoopy | last post by:
I have a customer order database and I need to pull a customers information, ie first name, last name, address, city, state, zip, phone, etc, into the oder table. i don't know how to go about...
1
by: Per | last post by:
Hi, I have a problem that I can't figure out. I have a database application to keep track of boxes that contain files. For data entry, I have a form with a main form section for the box-specific...
3
by: Kitana907 | last post by:
Hi- I am having issues with adding up fields in a subform. I have a form that has a subform in datasheet mode. It lists titles of books with their correlating units and dollar amount . The...
2
rsmccli
by: rsmccli | last post by:
Access 2002 Hi, I have a number of comboboxes/textboxes in the header of a form that the user selects values from. These comboboxes/textboxes correspond to controls in a datasheet view subform....
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
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
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...

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.