 |
| VB Databases Basics Beginning-level VB coding questions specific to using VB with databases. Issues not specific to database use will be redirected to other forums. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the VB Databases Basics section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

April 14th, 2005, 11:35 AM
|
|
Authorized User
|
|
Join Date: Apr 2005
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Gonzalo, Phil,
There is no error, it just doesn't make any alteration.
It's definitely selecting the right child because any alterations I make to the personal data in these loops are saved:
With rsChildTable
.MoveFirst
.Index = "PrimaryKey"
.Seek "=", lCurrentChildKey
If Not .NoMatch Then
rsChildTable.Edit
Else
MsgBox ("Ohhhh Nooo")
End If
End With
With rsChildTable
mskUPN.PromptInclude = False
If (Len(mskUPN)) Then !UPN = mskUPN
mskUPN.PromptInclude = True
If (Len(txtFirstName)) Then !FirstName = txtFirstName
If (Len(txtMiddleInitial)) Then !MiddleInitial = _
txtMiddleInitial
If (Len(txtLastName)) Then !LastName = txtLastName
If (Len(txtZip)) Then !HomeZip = txtZip
mskBirthday.PromptInclude = False
!Gender = cmbGender.Text
If (Len(mskBirthday.Text) > 0) Then
mskBirthday.PromptInclude = True
!Birthday = mskBirthday
lblBirthday = Format$(!Birthday, "dddd mmmm dd, yyyy")
End If
mskBirthday.PromptInclude = True
mskUPN.PromptInclude = True
.Update
End With
The red line is where the child is chosen (lCurrentChildkey) in another subroutine. So I assume it's a mistake/omission in the following loop:
ElseIf (iCurrentState = NOW_EDITING) Then
With rsChildTable
.MoveFirst
.Index = "PrimaryKey"
.Seek "=", lCurrentChildKey
If Not .NoMatch Then
With rsAchievedTable
For iCount = 1 To 383
.Edit
!Achieved = cmbAchieved(iCount - 1).Text
!Evidence = cmbEvidence(iCount - 1).Text
.Update
Next iCount
End With
Rob
|
|

April 14th, 2005, 01:25 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
ok.. let's see.. there is a flaw in this code...
since you have 2 fields that are key, you have to select every record for every child ...
in you editing loop, you are only selecting the first row of the 383, editing it, and then editing it again 382 more times since you are not changing the destination row!!!
you have to loop around the steppingstone_id to match every row that you need to update..
did i xplain well???
HTH
Gonzalo
|
|

June 13th, 2005, 11:07 AM
|
|
Authorized User
|
|
Join Date: Apr 2005
Posts: 11
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Hi Gonzalo,
Long time no speak. Unfortunately, I've been very ill and had 6 weeks in hospital, so I could not respond to your last post.
You suggest that I am simply updating the very first row 383 times. When I look at the code, that makes a lot of sense, but could you or Phil (if you're still around) tell me how I increment each stepping stone ID in the code. I appreciate that this is probably very easy, but with the layoff in hospital, my mind is a complete blank.
The existing code is as below:
With rsChildTable
.MoveFirst
.Index = "PrimaryKey"
.Seek "=", lCurrentChildKey
If Not .NoMatch Then
With rsAchievedTable
.Edit
For iCount = 1 To 383
!Achieved = cmbAchieved(iCount - 1).Text
!Evidence = cmbEvidence(iCount - 1).Text
.Update
Next iCount
End With
I really appreciate all the help you've given me so far and any help with this last problem would be very welcome.
thanks again
Rob
|
|

June 13th, 2005, 11:21 AM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
|
|
hi there..
hope you are ok now...
lets see.. you are updating 383 times the same record..
since your for...next statement only go through the controls on the form and not the recordset, you will probably need a seek inside the for...next to get every child..
i hope i remember well..
HTH
Gonzalo
|
|

June 13th, 2005, 01:08 PM
|
|
Authorized User
|
|
Join Date: Jun 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Really dumb question time...
Do you have your database files set to allow duplicates of information?
|
|
 |