Run-time error 2450

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
 
G

Graham Mandeno

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.
 
K

Kimberly

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


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top