Re: Combo Box Selection Code on NOT IN LIST
From: Dirk Goldgar (dg_at_NOdataSPAMgnostics.com)
Date: 06/14/04
- Next message: Binta Patel: "Error 3159 Not a Valid Bookmark"
- Previous message: John Vinson: "Re: Updating recordsets w/o losing original record"
- In reply to: Bob: "Combo Box Selection Code on NOT IN LIST"
- Next in thread: anonymous_at_discussions.microsoft.com: "Re: Combo Box Selection Code on NOT IN LIST"
- Reply: anonymous_at_discussions.microsoft.com: "Re: Combo Box Selection Code on NOT IN LIST"
- Messages sorted by: [ date ] [ thread ]
Date: Mon, 14 Jun 2004 14:10:13 -0400
"Bob" <drbobb1@hotmail.com> wrote in message
news:1bfb901c45237$702cf550$a601280a@phx.gbl
> Can someone tell explain why this works in one DB and not
> in the new one I am trying to create.
>
> Private Sub FIELDNAME_NotInList(NewData As String,
> Response As Integer)
> Dim strmsg As String
> Dim rst As Recordset
> Dim db As Database
> Const MB_YESNO = 4
> Const MB_Question = 32
> Const IDNO = 7
> strmsg = "'" & NewData & "' is not in list. "
> strmsg = strmsg & "Would you like to ad it?"
>
> If MsgBox(strmsg, MB_YESNO + MB_Question, "New
> Question") = IDNO Then
> Response = DATA_ERRDISPLAY
> Else
> Set db = DBEngine.Workspaces(0).Databases(0)
> Set rst = db.OpenRecordset("TABLENAME") <<<<
> IT ERRORS OUT HERE "type mismatch ERR0R 13"
> rst.AddNew
> rst("FIELDNAME") = NewData
> rst.Update
> Response = DATA_ERRADDED
> rst.Close
> End If
> End Sub
>
> If I change the TABLENAME to something that doesn't exist
> the error message that comes up I can understand >> "
> The Microsoft Jet database engine cannot find the input
> table or query <name>. Make sure it exists and that its
> name is spelled correctly. (Error 3078)"
I imagine it's because the database where it succeeds has a reference to
DAO and either doesn't have a reference to ADO or the DAO reference is
higher in the priority list, while the database where it fails either
has only a reference to ADO or (most likely) the ADO reference is higher
in the list of references. ADO and DAO both define a Recordset object,
and they aren't compatible. Safest is to disambiguate your declarations
of objects from these libraries, like this:
Dim rst As DAO.Recordset
Dim db As DAO.Database
Technically, you don't have to do it for the Database object, because
ADO has no Database object, but it's easier just to specify the library
for each declaration -- that way you don't have to keep the list of
common objects in your head.
-- Dirk Goldgar, MS Access MVP www.datagnostics.com (please reply to the newsgroup)
- Next message: Binta Patel: "Error 3159 Not a Valid Bookmark"
- Previous message: John Vinson: "Re: Updating recordsets w/o losing original record"
- In reply to: Bob: "Combo Box Selection Code on NOT IN LIST"
- Next in thread: anonymous_at_discussions.microsoft.com: "Re: Combo Box Selection Code on NOT IN LIST"
- Reply: anonymous_at_discussions.microsoft.com: "Re: Combo Box Selection Code on NOT IN LIST"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|