Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665

    Unanswered: Realy simple Question

    I kinda feel silly asking cause i know its very simple.
    How do u get the information that an end user would put into a msg box into a append query?
    Regards Jim

  2. #2
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665

    Re: Realy simple Question

    Originally posted by JDionne
    I kinda feel silly asking cause i know its very simple.
    How do u get the information that an end user would put into a msg box into a append query?
    Regards Jim
    OK i have the input box working..how do i write the update query to use the variable. im stuck on the from part...i dont have a tabel taht this is coming from its a varaiable.

    Regards
    Jim

  3. #3
    Join Date
    Apr 2003
    Posts
    21
    1- Using SQL:

    UPDATE table1 SET field1 = 123, field2 = "ldkfjlsdkj" ... etc

    2- Using ADO:

    use the command with the SQL statment as above OR

    use a Recordset, select the record you want to update
    e.g. "select * from table1 where field1=165465"
    and then just change the values
    finally call Update or UpdateBatch

    e.g.

    Dim db as ADODB.Connection
    Dim rs As ADODB.Recordset
    dim strConnection As string ' your connection string is here

    set db = new ADODB.Connection
    set rs = new ADODB.recordset

    db.open strConnection
    rs.open "select * from table1 where field1 = 23", db

    rs!field1 = 456
    rs!field2 = "jkdjsf"
    .. etc

    rs.Update
    OR rs.updateBatch

    Tip: Don't bother yourself with SQL queries, just use the query designer in MS Access (select the affected tables and don't forget to right click and select the query type from the context menu (select, update .. etc)
    then chage to the SQL view and copy!!

  4. #4
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665
    Originally posted by waleedfi
    1- Using SQL:

    UPDATE table1 SET field1 = 123, field2 = "ldkfjlsdkj" ... etc

    2- Using ADO:

    use the command with the SQL statment as above OR

    use a Recordset, select the record you want to update
    e.g. "select * from table1 where field1=165465"
    and then just change the values
    finally call Update or UpdateBatch

    e.g.

    Dim db as ADODB.Connection
    Dim rs As ADODB.Recordset
    dim strConnection As string ' your connection string is here

    set db = new ADODB.Connection
    set rs = new ADODB.recordset

    db.open strConnection
    rs.open "select * from table1 where field1 = 23", db

    rs!field1 = 456
    rs!field2 = "jkdjsf"
    .. etc

    rs.Update
    OR rs.updateBatch

    Tip: Don't bother yourself with SQL queries, just use the query designer in MS Access (select the affected tables and don't forget to right click and select the query type from the context menu (select, update .. etc)
    then chage to the SQL view and copy!!


    I think i have found a simpiler way...

    DoCmd.SetWarnings False
    Dim msganswer As String
    msganswer = InputBox("Enter New Make", "New Make")
    DoCmd.RunSQL "INSERT INTO COMPANY_TBL( Name )SELECT " & "'" & msganswer & "'"
    DoCmd.SetWarnings True

    i dont know how this works its a sql statment with out a from clause...but it seems to work during testing.
    Thanx for the help
    Jim

  5. #5
    Join Date
    Apr 2003
    Posts
    21
    Sorry .. but I thought you were talking about an update query!

    >OK i have the input box working..how do i write the "update query" to
    >use the variable. im stuck on the from part...i dont have a tabel taht
    >this is coming from its a varaiable.

  6. #6
    Join Date
    Aug 2002
    Location
    Charlotte NC
    Posts
    665
    Originally posted by waleedfi
    Sorry .. but I thought you were talking about an update query!

    >OK i have the input box working..how do i write the "update query" to
    >use the variable. im stuck on the from part...i dont have a tabel taht
    >this is coming from its a varaiable.
    aggg in my hast i used the wrong word. sorry about that
    thanx for the help
    Jim

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •