A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Using Forms
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

NotinList problem



 
 
Thread Tools Display Modes
  #1  
Old August 20th, 2006, 03:01 PM posted to microsoft.public.access.forms
LJG
external usenet poster
 
Posts: 68
Default NotinList problem

Hi Guys,
Using Allen Browne's 'not in table' method to add details to another table
and keep getting this error message:

error 3421: Data type conversion

I would assume from this message that the value is the wrong data type, but
it's not, the field is a text field?

If I click ok to the error message it puts a blank 'null value' record in
the relevant table.

Any ideas were I am going wrong?

TIA

Les


  #2  
Old August 20th, 2006, 04:20 PM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default NotinList problem

Without seeing the actual code you're using, it's pretty difficult for
anyone to comment.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"LJG" wrote in message
...
Hi Guys,
Using Allen Browne's 'not in table' method to add details to another table
and keep getting this error message:

error 3421: Data type conversion

I would assume from this message that the value is the wrong data type,
but it's not, the field is a text field?

If I click ok to the error message it puts a blank 'null value' record in
the relevant table.

Any ideas were I am going wrong?

TIA

Les




  #3  
Old August 20th, 2006, 04:31 PM posted to microsoft.public.access.forms
LJG
external usenet poster
 
Posts: 68
Default NotinList problem

No problem, this is my code:

Function Append2Table(cbo As ComboBox, NewData As Variant) As Integer
On Error GoTo Err_Append2Table
' Purpose: Append NotInList value to combo's recordset.
' Assumes: ControlSource of combo has the same name as the foreign key
field.
' Return: acDataErrAdded if added, else acDataErrContinue
' Usage: Add this line to the combo's NotInList event procedu
'Response = Append2Table(Me.MyCombo, NewData)
Dim rst As DAO.Recordset
Dim sMsg As String
Dim vField As Variant ' Name of the field to append to.

Append2Table = acDataErrContinue
vField = cbo.ControlSource
If Not (IsNull(vField) Or IsNull(NewData)) Then
sMsg = "Do you wish to add the entry " & NewData & " for " &
cbo.Name & "?"
If MsgBox(sMsg, vbOKCancel + vbQuestion, "Add new value?") = vbOK
Then
Set rst = CurrentDb.OpenRecordset(cbo.RowSource)
rst.AddNew
rst(vField) = NewData
rst.Update
rst.Close
Append2Table = acDataErrAdded
End If
End If

Exit_Append2Table:
Set rst = Nothing
Exit Function

Err_Append2Table:
MsgBox "Error " & Err.Number & ": " & Err.description, vbInformation,
"Append2Table()"
Resume Exit_Append2Table
End Function





"Douglas J. Steele" wrote in message
...
Without seeing the actual code you're using, it's pretty difficult for
anyone to comment.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"LJG" wrote in message
...
Hi Guys,
Using Allen Browne's 'not in table' method to add details to another
table and keep getting this error message:

error 3421: Data type conversion

I would assume from this message that the value is the wrong data type,
but it's not, the field is a text field?

If I click ok to the error message it puts a blank 'null value' record in
the relevant table.

Any ideas were I am going wrong?

TIA

Les






  #4  
Old August 20th, 2006, 05:55 PM posted to microsoft.public.access.forms
Douglas J. Steele
external usenet poster
 
Posts: 9,313
Default NotinList problem

So vField is a text field? What value are you trying to store in it?

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"LJG" wrote in message
...
No problem, this is my code:

Function Append2Table(cbo As ComboBox, NewData As Variant) As Integer
On Error GoTo Err_Append2Table
' Purpose: Append NotInList value to combo's recordset.
' Assumes: ControlSource of combo has the same name as the foreign key
field.
' Return: acDataErrAdded if added, else acDataErrContinue
' Usage: Add this line to the combo's NotInList event procedu
'Response = Append2Table(Me.MyCombo, NewData)
Dim rst As DAO.Recordset
Dim sMsg As String
Dim vField As Variant ' Name of the field to append to.

Append2Table = acDataErrContinue
vField = cbo.ControlSource
If Not (IsNull(vField) Or IsNull(NewData)) Then
sMsg = "Do you wish to add the entry " & NewData & " for " &
cbo.Name & "?"
If MsgBox(sMsg, vbOKCancel + vbQuestion, "Add new value?") = vbOK
Then
Set rst = CurrentDb.OpenRecordset(cbo.RowSource)
rst.AddNew
rst(vField) = NewData
rst.Update
rst.Close
Append2Table = acDataErrAdded
End If
End If

Exit_Append2Table:
Set rst = Nothing
Exit Function

Err_Append2Table:
MsgBox "Error " & Err.Number & ": " & Err.description, vbInformation,
"Append2Table()"
Resume Exit_Append2Table
End Function





"Douglas J. Steele" wrote in message
...
Without seeing the actual code you're using, it's pretty difficult for
anyone to comment.

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no private e-mails, please)


"LJG" wrote in message
...
Hi Guys,
Using Allen Browne's 'not in table' method to add details to another
table and keep getting this error message:

error 3421: Data type conversion

I would assume from this message that the value is the wrong data type,
but it's not, the field is a text field?

If I click ok to the error message it puts a blank 'null value' record
in the relevant table.

Any ideas were I am going wrong?

TIA

Les








 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 07:06 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.