Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update Code Works on one record, Not on next?

Status
Not open for further replies.

misscrf

Technical User
Jun 7, 2004
1,344
US
I have an application with a main entry form for new projects/cases. There are 3 sub forms -
Custodians - people who will give us data for the project
Assets - data on media for the project (1 asset may have multiple custodian stuff on it)
Asset Custodians - a many/many linking form to tie each asset to any custodians having data on it.

I created code that runs on a command button from the main form. A user -
1) clicks the record selector of a single record on the custodian sub form
2) clicks the record selector of a single record on the asset sub form
3) clicks the command button to assign asset custodian relationship.

The command button will generate a new record in the asset/custodian key table and populate the sub form with the keys for the selected records from the other 2 sub forms. This works for the first case/project record.

When I go to the second case/project record, the new case asset custodian record seems to be generated, but no values show up in the sub form. I traced through all the look ups of the tables and found that it looks like the key case asset custodian table got updated.

This is the code I have in the onclick of the command button:
Code:
Private Sub cmdAddCaseAssetCust_Click()
Dim frm As Form
Set frm = Me.frmCaseAssetCustodian.Form
With frm.RecordsetClone
.AddNew
![FKCaseAsset] = [frmCaseAsset].Form![PKHBCaseAssetKeyID]
![FKHBCaseCustodian] = [frmCaseCustodian].Form![PKHBCaseCustodianKeyID]
.Update
frm.Bookmark = .LastModified
End With
Set frm = Nothing
[frmCaseAsset].Form![PKHBCaseAssetKeyID].Requery
[frmCaseCustodian].Form![PKHBCaseCustodianKeyID].Requery

End Sub

This shows the first case/project record and what it looks like
First Case Record with Correctly Added Case Asset Custodian Record
You can see the record selectors on the two left sub forms, the command button on the main form and the selected, added record on the 3rd right sub form.

Here is the image of the second case/project record, where there is a blank case asset custodian record added in the third sub form but no values are showing in the combos Second Case Record with Blank Added Case Asset Custodian Record

I close out of the entry form, go back in, cycle records. It never shows. But the back end tables look like this record is now in the table.

I have not been thinking it is related, but for full disclosure and troubleshooting, when I open the main entry form, I get a type mismatch error, hit ok and then nothing. I can proceed about my business.

Anyone able to help me with this quandary, please?

Thanks!

misscrf

It is never too late to become what you could have been ~ George Eliot
 
Can anyone please let me know if I am missing information that might help someone to help me? I tried to be detailed, but alas, no responses.

sad face :-(

misscrf

It is never too late to become what you could have been ~ George Eliot
 
Nevermind. I figured it out. I had filters everywhere! I had correct master child links, but then I had those same filters on the control source of the subform and on each combo box! Talk about overkill lol.



misscrf

It is never too late to become what you could have been ~ George Eliot
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top