Results 1 to 3 of 3
  1. #1
    Perfac's Avatar
    Perfac is offline Expert
    Windows 7 64bit Access 2016
    Join Date
    May 2016
    Location
    Centurion Pretoria
    Posts
    618

    Vba on form

    Form f02InvPurchase. The following code is on the VBA page. The first part is working fine. When I click on control T003 it also put whatever is in *ID03 in *ID05 since it is all in the source query. I want to know if it is possible to write to an external table or query. The next line q01InventoryItem!LtstPrce = UnitPrice05 is not doing the job. As said the local form and query is f02InvPurchase and q02InvPurchase. It is field UnitPrice05 in q02InvPurchase that I want to be written to the external query.

    Private Sub T003_Click()


    If (Me.T001) = 2 Then
    Me!CmbEnt_ID15 = Me!CmbEnt_ID03
    q01InventoryItem!LtstPrce = UnitPrice05
    End If
    End Sub

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    you cant write directly to a query, but,
    you can put in a subform connected to the query, then write to the subform

    me.subform.form.LtstPrce = me.UnitPrice05


  3. #3
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    To write to a query, the query MUST be open - stand alone or as a record source to a form.

    You could open the query in code (in a recordset), update the field, then save and close the recordset.
    BUT.... how many records will be returned in the query "q01InventoryItem"? Be careful you don't update EVERY record in the query (unless you want every record updated).

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

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