473,757 Members | 5,404 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Reading all values from datasheet subform

8 New Member
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!ztestatt 2!zsfrmattrib.F orm!consel.Valu e = -1) Then
aattID = Forms!ztestatt2 !zsfrmattrib.Fo rm!categoryID.V alue
asel = Forms!ztestatt2 !zsfrmattrib.Fo rm!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 4947
paulw4
8 New Member
OK, I have been researching the record set clone and movenext features and have the following code

Set frm1 = Forms("ztestatt 2")
Set ctl1 = frm1.zsfrmattri b

Debug.Print frm1.RecordSour ce
Debug.Print ctl1.Form.Recor dSource
Debug.Print ctl1.Form.Recor dsetClone.Recor dCount
Debug.Print

For int2 = 0 To ctl1.Form.Recor dsetClone.Recor dCount - 1


Debug.Print int2, ctl1.Controls!C ategoryID _
, ctl1.Controls!C ategory _
& " " & ctl1.Controls!c onsel
' ctl1.Form.Recor dsetClone.MoveN ext

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 Recognized Expert Specialist
OK, I have been researching the record set clone and movenext features and have the following code

Set frm1 = Forms("ztestatt 2")
Set ctl1 = frm1.zsfrmattri b

Debug.Print frm1.RecordSour ce
Debug.Print ctl1.Form.Recor dSource
Debug.Print ctl1.Form.Recor dsetClone.Recor dCount
Debug.Print

For int2 = 0 To ctl1.Form.Recor dsetClone.Recor dCount - 1


Debug.Print int2, ctl1.Controls!C ategoryID _
, ctl1.Controls!C ategory _
& " " & ctl1.Controls!c onsel
' ctl1.Form.Recor dsetClone.MoveN ext

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 New Member
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 Recognized Expert Specialist
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
5359
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 entering customers and their respective orders, the first order entered is fine with the "tab" field orders correct. On the second and subsequent orders, when I go from the Order form to the subform "OrderDetail", the curser goes to the wrong field...
1
2323
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 position I wanted it. No records are returned by the form's query (it has a "Where ID = -1" clause and the GoToRecord proc on the main form changes the subform's recordsource). When I opened the form and started adding data to the subform,...
5
8628
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, and the subform Detail section's Can Grow property is Yes. The report Detail section's Can Grow property is also Yes. When run, the select query's memo field has all the data. However, when I run the report, the subform does not show all the...
7
6261
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 subform is for parts used on the work order. On the main form I have a LaborTotal (from main form), PartsTotal (from subform) and TotalCost (which is Labor + Parts). All works fine as is. Now to the question: I have a button on my main form to browse...
1
3072
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. The unbound controls are populated in the subform's OnCurrent even from a number of different tables related to the records in tbl_tasks, which is the recordset displayed in the subform.
2
946
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 making this work...
1
2358
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 data (box description etc), and a subform for entering details on each file that's in the box (type, subtype etc). The subform is in a datasheet form, with one record on each row. Some of the subform fields are filled in using drop-downs,...
3
3642
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 user will be able to delete records from this subform. I am trying to add in text boxes that list the sum of oh, the sum of extretail, and the count of titles. I have tried it the three ways below with no luck... (I'll give examples with the OH...
2
4255
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. When a new record is created in the subform I want these values to automatically write to the new record in the subform. Right now I have this autofill procedure running on the AfterInsert event of the subform. It works well, except for the fact...
0
10069
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9884
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8736
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7285
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6556
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5168
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5324
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3828
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2697
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.