Re: Insert statement not updating table?



Thanks. I didn't know you could do it that way too. I'm used to entering
straight SQL statements and not using them in VBA code...I had realized my
statement was incorrect when msgbox kindly displayed the SQL statement being
executed for me. Just started learning VB & I really appreciate the quality
help I get from this forum. :)

Rick Brandt wrote:
>> Hello,
>>
>[quoted text clipped - 11 lines]
>> another table, with RecID being the related field. Any thoughts?
>> MsgBox [Num] is returning the correct value...
>
>In VBA code in your form's module [Num] means something. It refers to the
>control or field on the form with the name "Num". In a SQL String it is
>just 5 characters being passed to the Jet database engine and Jet does not
>know anything about your form at the time of execution. (You should be
>getting an error or a parameter prompt).
>
>You need to delimit the string so that the string ends up with the values
>contained in [Num] and [ContactDate] instead of the reference to them (since
>Jet cannot evaluate that reference).
>
>SQL1 = "INSERT INTO tblContactDateHistory ( RecID, ContactDate) " & _
> "Values ( " & Me![Num] & ", #" & Me![ContactDate] & "#)"
>DoCmd.RunSQL SQL1
>


--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-formscoding/200508/1
.



Relevant Pages

  • RE: run SQL SELECT query in vba
    ... > can not construct & run simple SELECT SQL statements ... > checkmark the "Microsoft DAO 3.6 Object Library"? ... > selects criteria to query my tables by. ... > So I was thinking about writing vba code ...
    (microsoft.public.access.queries)
  • Re: How to write long string sentences
    ... Do you want to manage long SQL statements or do you want to manage long ... trying to manipulate the SQL statement as a string. ... I still question if you are wanting long string manipulation or simply ... If for some reason you don't want to use Visual Designers for managing your ...
    (microsoft.public.dotnet.languages.vb)
  • Re: Which is best - recordsets/VBA V SQL statements for updating data
    ... By this I mean if I had to do some intensive processing that resulted in data in temp tables, I would have VBA code that wrote the results of that away to the db, either creating new records or updating existing records, whichever was relevant. ... His code includes constructing SQL statements that he then executes to make the changes. ... One example of a combination approach might be where you need to update a specific group of records using a complex formula implemented as a VBA function. ...
    (comp.databases.ms-access)
  • Re: User Define Array Data Type - Subscript out of range
    ... The absolute fastest way to do what you want would be to use SQL statements instead of looping code, but that would, of course, depend on what all you need to do. ... strDataType As String ... ' Load Array ...
    (microsoft.public.access.modulesdaovba)
  • Re: How to run update batch query
    ... You just want to read the SQL statements from a text file and then run them? ... Open one text file via VBA, and run the SQL statement that you read from ... > need to use this file to update my database which is big challenge for me. ... >> hmm, perhaps i'm in over my head here, Sarah. ...
    (microsoft.public.access.macros)

Loading