Gasman
Enthusiastic Amateur
- Local time
- Today, 19:13
- Joined
- Sep 21, 2011
- Messages
- 17,341
Hi all,
I have this piece of code in two forms. The table name and form name would differ, but the rest is teh same.
I have two buttons on a form to open these two forms. Up until now it had been working fine.
If the child record is not there, it allows me to add a new record. If a record is there it opens to the correct record(s)
As you can see I tried another method, which I've commented out as I preferred doing the check in the called form, eliminating a lot of checking in any calling form.
If I'd just created this I'd understand, but I entered a pile of data last week using this process, and unaware of making any changes to break this. :banghead:
The forms are based on tables, so a nonupdatable query is not the culprit
Just looking for tips as where to look to get to the bottom of this. If I click End to the error message the form opens normally I can continue to enter data for the new record?
Just when you think you are getting somewhere, something like this happens.
If someone has a better method, I'm open to ideas? I just wanted a button to call a form. If the child record does not exist for the parent, then add a new record with the parent id. If it does exist, then open, but still allow for new records with the parentID to be added.
TIA
Edit: Just realised a did a repair install on Office due to the Outlook 2007 spellcheck bug after the Windows 10 Creators update, but that is all I can think of. Not changed any tables etc.
I have this piece of code in two forms. The table name and form name would differ, but the rest is teh same.
Code:
Private Sub Form_Load()
Dim lngID As Long
If Not IsNull(Me.OpenArgs) Then ' Passing in the client ID means we want a new record.
Me.ClientID = Me.OpenArgs
lngID = Nz(DLookup("ClientID", "tblTransfer", "ClientID = " & Me.ClientID), 0)
If lngID = 0 Then
DoCmd.GoToRecord , , acNewRec
End If
End If
End Sub
If the child record is not there, it allows me to add a new record. If a record is there it opens to the correct record(s)
Code:
Private Sub cmdTransfer_Click()
' Save the record first so the name appears in next form
If Me.Dirty Then
Me.Dirty = False
End If
'If IsNull(DLookup("ClientID", "tblTransfer", "ClientID = " & Me.ClientID)) Then
'DoCmd.OpenForm "frmTransfer", , , , , acDialog, Me.ClientID
'Else
'DoCmd.OpenForm "frmTransfer", , , "ClientID = " & Me.ClientID, , acDialog
'End If
'Now check in form being called
DoCmd.OpenForm "frmTransfer", , , "ClientID = " & Me.ClientID, , acDialog, Me.ClientID
End Sub
If I'd just created this I'd understand, but I entered a pile of data last week using this process, and unaware of making any changes to break this. :banghead:
The forms are based on tables, so a nonupdatable query is not the culprit
Just looking for tips as where to look to get to the bottom of this. If I click End to the error message the form opens normally I can continue to enter data for the new record?
Just when you think you are getting somewhere, something like this happens.

If someone has a better method, I'm open to ideas? I just wanted a button to call a form. If the child record does not exist for the parent, then add a new record with the parent id. If it does exist, then open, but still allow for new records with the parentID to be added.
TIA
Edit: Just realised a did a repair install on Office due to the Outlook 2007 spellcheck bug after the Windows 10 Creators update, but that is all I can think of. Not changed any tables etc.