G
Gina
Hi all.
I have created a table
TextID autonumber
Description text
on my form a cboBox takes its data directly from the table
SELECT [tblText].[TextID], [tblText].[Description] FROM tblText;
both columns are shown, only data from list: NO
What I would like to do is when a description is not already in the table,
to add the new one as new record and requery the cboBox to reflect the newly
done adding.
This is my code and when I try to show the new record in the cboBox I get a
message that I first have to save the field ????? line ***
__________________________________________________________
Private Sub cboText_NotInList(NewData As String, Response As Integer)
Dim strSQL As String
Dim rs As DAO.Recordset
strSQL = "SELECT COUNT(tblText.Description) FROM tblText WHERE
tblText.Description = '" & NewData & "' "
Set rs = CurrentDb.OpenRecordset(strSQL)
If rs.AbsolutePosition = 0 Then
strSQL = "INSERT INTO tblText(Description) VALUES ( '" & NewData &
"' )"
DoCmd.RunSQL (strSQL)
End If
Response = acDataErrContinue
*** 'cboText.Requery
End Sub
_____________________________________________________________
Many Thanks
Gina
I have created a table
TextID autonumber
Description text
on my form a cboBox takes its data directly from the table
SELECT [tblText].[TextID], [tblText].[Description] FROM tblText;
both columns are shown, only data from list: NO
What I would like to do is when a description is not already in the table,
to add the new one as new record and requery the cboBox to reflect the newly
done adding.
This is my code and when I try to show the new record in the cboBox I get a
message that I first have to save the field ????? line ***
__________________________________________________________
Private Sub cboText_NotInList(NewData As String, Response As Integer)
Dim strSQL As String
Dim rs As DAO.Recordset
strSQL = "SELECT COUNT(tblText.Description) FROM tblText WHERE
tblText.Description = '" & NewData & "' "
Set rs = CurrentDb.OpenRecordset(strSQL)
If rs.AbsolutePosition = 0 Then
strSQL = "INSERT INTO tblText(Description) VALUES ( '" & NewData &
"' )"
DoCmd.RunSQL (strSQL)
End If
Response = acDataErrContinue
*** 'cboText.Requery
End Sub
_____________________________________________________________
Many Thanks
Gina