Runtime err: 2450 (1 Viewer)

donsi

Registered User.
Local time
Today, 06:33
Joined
Sep 1, 2016
Messages
73
Hello,

I have a sub form AddEditEmployee within main form Admin. Both forms are not linked and only purpose of the subform is to Add/update users. I am getting error 2450 when the AddEditEmployee form is inserted as subform in the Admin form, but when open as stand alone, it doesn't throw an error when data is modify or added.

Code:
Private Sub cmdSave_Click()
Dim prm As DAO.Parameter
Dim qdf As DAO.QueryDef
Dim rs As DAO.Recordset

        Set qdf = CurrentDb.QueryDefs("qryUpdateUser")
        For Each prm In qdf.Parameters
            prm.Value = Eval(prm.Name)
        Next prm
        
        qdf.Execute dbSeeChanges + dbFailOnError
       
Me.cmdAdd.Enabled = True
    Me.cmdSave.Enabled = False
    Me.txtUserName = ""
    Me.txtEmpName = ""
    Me.CboAccess = ""
    Me.txtLicNo = ""
    Me.chkDeActive = 0
    Me.cmbEmp = ""
    Me.txtPin = ""
    Me.txtEmpName.SetFocus
    Me.Refresh
End Sub

Value is null for that.

Code:
prm.Value = Eval(prm.Name)
 

Attachments

  • 2019-01-21.bmp
    82.1 KB · Views: 69

pbaldy

Wino Moderator
Staff member
Local time
Today, 06:33
Joined
Aug 30, 2003
Messages
36,118
This is the one you're after:

Forms!Mainform!Subform1.Form!ControlName

using your object names of course.
 

donsi

Registered User.
Local time
Today, 06:33
Joined
Sep 1, 2016
Messages
73
This is the one you're after:

Forms!Mainform!Subform1.Form!ControlName

using your object names of course.

"Eval(prm.Name)" only ready Forms!Subform!ControlName rather than reading it like suggested. I googled to find any documents or post that may help with this, but unable to locate one. Not sure even if it is possible.
 

Micron

AWF VIP
Local time
Today, 09:33
Joined
Oct 20, 2018
Messages
3,476
"Eval(prm.Name)" only ready Forms!Subform!ControlName rather than reading it like suggested.
qryUpdateUser likely has a field that refers to the subform. That's where the validation fails when the subform calls it, and that's likely because you haven't put the correct subform reference in that query field. Try that, and if not successful, you should post
- main form name
- subform control name (NOT the name of the subform unless they happen to be the same, which is not advised)
- name of the field being referenced on the subform
Keep in mind that a subform loads first, so if you are trying to get any values from the main form when subform loads, it will fail.
 

pbaldy

Wino Moderator
Staff member
Local time
Today, 06:33
Joined
Aug 30, 2003
Messages
36,118
Did you change it in the query itself?
 

Users who are viewing this thread

Top Bottom