J
Joanne
I am using Office 2003 on WinXP
My database has this table TblMain
2 Columns in table, Name and Location
The form has a cboName and cboLocation
Choices in cboLocation are determined by value in cboName
When the choice I want is not in cboName, I want to be able to put it
in the cbobox and have it write to the table, and then do same in
cboLocation.
I have property 'LimitToList' set to No, and bound col1 for cboName
and bound col2 for cboLocation
In the 'On NotInList' event on cboName I have this snippet of code
that I got from 'The Access Web' (Great place for us newbies)
Private Sub cboName_NotInList(NewData As String)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("tblMain", dbOpenDynaset)
rs.AddNew
rs!cboName = NewData
rs.Update
End Sub
This lets me type a new Name in the cboName control, but it will not
write the newData to the table. I can't figure it out. I think I have
the properties properly set. After entering the new name, I tab to
the next control, then use navigation buttons to go to the next record
thinking that this will force the write to table, but it does not do
it.
Do I need to put a command button on my form to allow me to write to
the table if I need to add new data? That's the only other thing I
can think of - not really the way I would like to do it but I can if
need be.
As I read thru this note, I am thinking the problem is in the line
rs!cboName = New Data - isn't this failing to tell the app to write to
the table, instead just making the value of the cbobox equal to the
newData? If so, what should it say please?
Thanks for your help on this
Joanne
My database has this table TblMain
2 Columns in table, Name and Location
The form has a cboName and cboLocation
Choices in cboLocation are determined by value in cboName
When the choice I want is not in cboName, I want to be able to put it
in the cbobox and have it write to the table, and then do same in
cboLocation.
I have property 'LimitToList' set to No, and bound col1 for cboName
and bound col2 for cboLocation
In the 'On NotInList' event on cboName I have this snippet of code
that I got from 'The Access Web' (Great place for us newbies)
Private Sub cboName_NotInList(NewData As String)
Dim db As DAO.Database
Dim rs As DAO.Recordset
Set db = CurrentDb
Set rs = db.OpenRecordset("tblMain", dbOpenDynaset)
rs.AddNew
rs!cboName = NewData
rs.Update
End Sub
This lets me type a new Name in the cboName control, but it will not
write the newData to the table. I can't figure it out. I think I have
the properties properly set. After entering the new name, I tab to
the next control, then use navigation buttons to go to the next record
thinking that this will force the write to table, but it does not do
it.
Do I need to put a command button on my form to allow me to write to
the table if I need to add new data? That's the only other thing I
can think of - not really the way I would like to do it but I can if
need be.
As I read thru this note, I am thinking the problem is in the line
rs!cboName = New Data - isn't this failing to tell the app to write to
the table, instead just making the value of the cbobox equal to the
newData? If so, what should it say please?
Thanks for your help on this
Joanne