Results 1 to 4 of 4
  1. #1
    cougercruiser is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Oct 2012
    Posts
    1

    Form Selections to convert on table?

    Hi Guys,

    I've created a ComboBox and would like one of my selections: "Met" to be converted into a number value: "10" within the related field on the table.

    I've come up with the expression: =IF([Initial Review Q1]="Met",0,10)



    Control Source accepts the expression, however when I go back to Form View and select "Met" access chimes and states: "Control can't be edited it's bound to the expression =if([Initial Review Q1]="met",0,10)"



    I apologize, I am still in the early stages of learning access. Hopefully this video can shed some more light on my problem:

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,597
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    istari88 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Kentucky, USA
    Posts
    13

    Use VBA

    This is a good place for a data macro, new to Access 2010. A data macro acts like a trigger on the table

    Maybe VBA code like:
    Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    With rs
    .ActiveConnection = CurrentProject.Connection
    .CursorType = adOpenKeyset
    .LockType = adLockOptimistic
    .Open "tblName", , , , adCmdTable
    End With
    With rs
    .MoveFirst
    .Find "RecordID='" & variable & "'"
    !New_value = 10
    .Update
    ' If .EOF Then
    ' MsgBox "Not found"
    ' Exit Sub
    ' End If
    Me.txtCarPrice = rs!CarPrice
    End With
    rs.Close

    --hope it helps!
    --Phil

  4. #4
    istari88 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Kentucky, USA
    Posts
    13

    To clearify

    To add to my post:
    1) Use the combobox_after_update event to place all the code as below

    2) Save the record so that it has a record ID
    docmd.runcmd.....
    3) Place the recordID in a variable
    dim var as integer
    var=RecordID


    4) Open table, find record, add "10" to table at the right record
    Dim rs As ADODB.Recordset
    Set rs = New ADODB.Recordset
    With rs
    .ActiveConnection = CurrentProject.Connection
    .CursorType = adOpenKeyset
    .LockType = adLockOptimistic
    .Open "tblName", , , , adCmdTable
    End With

    With rs
    .MoveFirst
    .Find "RecordID='" & var & "'"
    If .EOF then exit sub
    !New_value = 10 'New_value is the field name of table
    .Update


    End With
    set rs=nothing


    ==Give that a try, let me know if this helps or I can add to it
    -Phil

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

Similar Threads

  1. Replies: 2
    Last Post: 06-19-2012, 08:30 AM
  2. Adding selections to some sort of table
    By shabbaranks in forum Access
    Replies: 15
    Last Post: 10-18-2011, 07:45 PM
  3. Replies: 9
    Last Post: 01-20-2011, 02:22 PM
  4. Convert form to Table or Add Field to Table
    By jlclark4 in forum Forms
    Replies: 1
    Last Post: 12-15-2010, 01:52 PM
  5. Replies: 1
    Last Post: 03-02-2009, 11:54 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