Error 438 - Object does not support this property or method (1 Viewer)

Ally

Registered User.
Local time
Today, 23:55
Joined
Sep 18, 2001
Messages
617
Aarrrggh! I have a form where I keep getting this error message. First of all it was another message, which was

"You can't add or change a record because a related record is required in table 'Episode'"

Managed to sort that sticking a couple of DoCmd.RunCommand acCmdSaveRecord in.

The 438 error message happens when clicking a command button after choosing data from two unbound combo boxes to add that data to a subform.

I have checked for Null values, and have set the default values in the subform fields to Null but I'm still getting it. It's weird though, because after I OK the error message, sometimes, it adds the data fine as it should do and other times not!

I've searched the archives and got some helpful information, but the majority of the Error 438 posts don't have replies.

Please, can anyone throw any light on this?
 
well, this error:
You can't add or change a record because a related record is required in table 'Episode'

is due to referential integrity. You should fix this properly. Your primary table (Episode) that joins to the other foreign table must have a record first before a related record can be added to the Foreign Key table. I would fix this first before doing any more development.
 
Thanks for replying ...

...is due to referential integrity. You should fix this properly. Your primary table (Episode) that joins to the other foreign table must have a record first before a related record can be added to the Foreign Key table. I would fix this first before doing any more development

It does though ... It's an autonumber that's automatically assigned when the form opens.
 
ok , post us your command button code.
 
Code:
Private Sub cmdAddICD_Click()
On Error GoTo lerror

Dim bx1 As Variant, x As Integer, y As String, z As Variant, r As Recordset
Dim db As Database, aa As Variant, bb As Variant, cc As Variant
Set db = CurrentDb
Set r = db.OpenRecordset("PtICD10")


10: x = Me.EpisodeID.Value
y = Me.cboICDCategory.Column(0)
z = Me.cboICDCode.Column(1)
cc = Me.UnitNo

'posts new codes into tblEpisodeICDDiag table
20: r.AddNew
r.Fields("EpisodeID") = x
r.Fields("ICDCategoryID") = y
r.Fields("ICDCode") = z
r.Fields("UnitNo") = cc

r.Update
DoCmd.Requery "EpisodeICDCodeSubform"

bx1 = msgbox("Do you want to enter any more episode diagnosis codes" _
& " for this person?", vbYesNo + vbQuestion, "Note")
If bx1 = vbYes Then
    
    Me.cboICDCategory.Value = ""
    Me.cboICDCode.Value = ""
    
    DoCmd.GoToControl "cboICDCategory"
Else
    
    Me.cboICDCategory.Value = ""
    Me.cboICDCode.Value = ""

    Exit Sub
    End If
    
lexit:
    Exit Sub
lerror:
    msgbox Err.Description
    Resume lexit
End Sub
 
Did you manage to get anywhere with this please?
 

Users who are viewing this thread

Back
Top Bottom