Run-time error 2450

  • Thread starter Thread starter Kimberly
  • Start date Start date
K

Kimberly

Does anyone know how to reference the value of a combo box
in a form from another form? Any help you can provide is
much appreciated.

Public Sub cmdequipment_Click()
Dim dbMyDB As Database

Set dbMyDB = CurrentDb

Dim rsMyRS As DAO.Recordset

Set rsMyRS = dbMyDB.OpenRecordSet
("tbl_equipmentparts_list", dbOpenDynaset)

rsMyRS.AddNew

rsMyRS!Login_id = Forms!frm_login.Controls!
cboEmployee.Value

rsMyRS.Update

End Sub
 
Hi Kimberley

The message for this error is:

Microsoft Access can't find the form '<form name>' referred to in a macro
expression or Visual Basic code.
* The form you referenced may be closed or may not exist in this database.
* Microsoft Access may have encountered a compile error in a Visual Basic
module for the form.

Are you sure the form "frm_login" is open at the time this code is running?
If so, try compiling your whole project (from the VB IDE Debug menu) to make
sure all your code is OK.
 
Good Catch.

The form for which I was trying to grab data was not open
and also I needed to remove the .value

Thanks for all your help!
-----Original Message-----
Hi Kimberley

The message for this error is:

Microsoft Access can't find the form '<form name>' referred to in a macro
expression or Visual Basic code.
* The form you referenced may be closed or may not exist in this database.
* Microsoft Access may have encountered a compile error in a Visual Basic
module for the form.

Are you sure the form "frm_login" is open at the time this code is running?
If so, try compiling your whole project (from the VB IDE Debug menu) to make
sure all your code is OK.

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

Kimberly said:
Does anyone know how to reference the value of a combo box
in a form from another form? Any help you can provide is
much appreciated.

Public Sub cmdequipment_Click()
Dim dbMyDB As Database

Set dbMyDB = CurrentDb

Dim rsMyRS As DAO.Recordset

Set rsMyRS = dbMyDB.OpenRecordSet
("tbl_equipmentparts_list", dbOpenDynaset)

rsMyRS.AddNew

rsMyRS!Login_id = Forms!frm_login.Controls!
cboEmployee.Value

rsMyRS.Update

End Sub


.
 
Back
Top