Results 1 to 4 of 4
  1. #1
    Overdive is offline Novice
    Windows 7 Access 2007
    Join Date
    Oct 2009
    Posts
    9

    Pulling value

    Hello
    I am trying to pull the value of the textbox (which is bound to a table field) then use that value in an SQL statement.
    The SQL statement I am using works fine for values that I specify.

    Here is the code

    Dim del_var As String

    Part_ID_PART.SetFocus (Part_ID_PART is the name of the control)
    del_var = Part_ID_PART.Value


    DoCmd.RunSQL "DELETE * FROM [PART]" & _
    "WHERE [PART ID] =del_var ;"


    I also tried Part_ID_PART.Text and didn’t work.
    However I do get a msgbox asking for del_var value and when I enter that it works but obviously I don’t want that msgbox to pop up

    Any help would be appreciated .



    Thank you

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows XP Access 2002
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    There is no reason to move the focus unless you *must* use the .Text property. Nor do you need the variable. So...

    DoCmd.RunSQL "DELETE * FROM [PART] WHERE [PART ID] =" & Me.Part_ID_PART & ";"

    ...should work if [PART ID] is numerical and...

    DoCmd.RunSQL "DELETE * FROM [PART] WHERE [PART ID] ='" & Me.Part_ID_PART & "';"

    ...if [PART ID] is a text field.

  3. #3
    Overdive is offline Novice
    Windows 7 Access 2007
    Join Date
    Oct 2009
    Posts
    9
    thank you that worked.

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows XP Access 2002
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Glad I could help.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Does it Matter? Pulling fields in a query
    By Canadiangal in forum Access
    Replies: 1
    Last Post: 10-01-2009, 01:53 AM
  2. Pulling Record Info From Sub Form
    By redlich23 in forum Forms
    Replies: 1
    Last Post: 09-02-2009, 02:10 PM
  3. Replies: 0
    Last Post: 07-27-2009, 07:51 AM
  4. Pulling out duplicates
    By FREEEEEEDOM in forum Access
    Replies: 1
    Last Post: 04-21-2009, 10:37 PM
  5. Pulling most recent data from child table
    By davidv43 in forum Access
    Replies: 0
    Last Post: 02-07-2009, 11:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums