Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 01-21-2019, 01:39 PM   #1
donsi
Newly Registered User
 
Join Date: Sep 2016
Posts: 65
Thanks: 41
Thanked 1 Time in 1 Post
donsi is on a distinguished road
Runtime err: 2450

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)
Attached Images
File Type: bmp 2019-01-21.bmp (82.1 KB, 26 views)

donsi is offline   Reply With Quote
Old 01-21-2019, 02:09 PM   #2
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 32,498
Thanks: 10
Thanked 3,957 Times in 3,896 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: Runtime err: 2450

The syntax to refer to the form changes when it's a subform:

http://theaccessweb.com/forms/frm0031.htm
__________________
Paul
Microsoft Access MVP

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is online now   Reply With Quote
The Following User Says Thank You to pbaldy For This Useful Post:
donsi (01-22-2019)
Old 01-22-2019, 12:40 PM   #3
donsi
Newly Registered User
 
Join Date: Sep 2016
Posts: 65
Thanks: 41
Thanked 1 Time in 1 Post
donsi is on a distinguished road
Re: Runtime err: 2450

Quote:
Originally Posted by pbaldy View Post
The syntax to refer to the form changes when it's a subform:

http://theaccessweb.com/forms/frm0031.htm
I looked at it prior to posting the thread, I just don't know how to reference it.

donsi is offline   Reply With Quote
Old 01-22-2019, 01:33 PM   #4
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 32,498
Thanks: 10
Thanked 3,957 Times in 3,896 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: Runtime err: 2450

This is the one you're after:

Forms!Mainform!Subform1.Form!ControlName

using your object names of course.
__________________
Paul
Microsoft Access MVP

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is online now   Reply With Quote
Old 02-11-2019, 12:12 PM   #5
donsi
Newly Registered User
 
Join Date: Sep 2016
Posts: 65
Thanks: 41
Thanked 1 Time in 1 Post
donsi is on a distinguished road
Re: Runtime err: 2450

Quote:
Originally Posted by pbaldy View Post
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.
donsi is offline   Reply With Quote
Old 02-11-2019, 01:45 PM   #6
Micron
Newly Registered User
 
Join Date: Oct 2018
Location: Ontario, Canada
Posts: 238
Thanks: 2
Thanked 35 Times in 33 Posts
Micron will become famous soon enough Micron will become famous soon enough
Re: Runtime err: 2450

Quote:
Originally Posted by donsi View Post
"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.
__________________
Windows 10; Office 365 (Access 2016)
Micron is offline   Reply With Quote
Old 02-11-2019, 02:17 PM   #7
pbaldy
Wino Moderator
 
pbaldy's Avatar
 
Join Date: Aug 2003
Location: Nevada, USA
Posts: 32,498
Thanks: 10
Thanked 3,957 Times in 3,896 Posts
pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold pbaldy is a splendid one to behold
Re: Runtime err: 2450

Did you change it in the query itself?


__________________
Paul
Microsoft Access MVP

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
pbaldy is online now   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Error 2450 kirkm Forms 12 05-26-2018 10:04 PM
> Access Will Not Save Picture Appropriately .... Form VBA Runtime Error 2450, Acces emax79 General 4 04-28-2014 04:41 PM
[SOLVED] Run-Time error 2450 gizmogeek Forms 3 04-24-2013 06:51 PM
Vba-run time err 2450 arage Modules & VBA 3 01-04-2001 07:49 PM




All times are GMT -8. The time now is 09:58 AM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World