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
4 4917
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
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. -
................
-
Dim RS as DAO.Recordset
-
.............................
-
Set RS = ctl1.Form.RecordsetClone
-
-
With RS
-
.MoveFirst
-
While Not .EOF
-
Debug.Print ![Field1Name];" "; ![Field2Name] ...............
-
Wend
-
End With
-
................
-
Set RS = Nothing
-
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
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 - Field; Type; IndexInfo
-
StudentID; AutoNumber; PK
-
Family; String; FK
-
Name; String
-
University; String; FK
-
Mark; Numeric
-
LastAttendance; Date/Time
Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
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...
|
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,...
|
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...
|
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....
|
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...
|
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...
|
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...
|
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....
|
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
|
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: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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: 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,...
|
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: 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...
| |