Results 1 to 3 of 3
  1. #1
    Join Date
    Mar 2010
    Posts
    2

    Unanswered: Recordset syntax for primary key consisting of two or more fields (VBA)

    Hello,

    I have a table Customers that has primary key consisting of one field CustomerID.

    Im working with unbound fields on form and i have one listbox that shows 3 of 8 (5 are hidden) columns, and 5 unbound fields next to listbox (1 is invisible for user – thats CustomerID)

    Listbox has afterupdate event to fill those 5 unbound fields.
    All 5 unbound fields are set to be disabled by default.

    When user wants to change data for selected customer he would click on command button that will fire an event to enable those fields for editing.

    After user is finished changing data he clicks command button „Save“ which has on click event which uses CustomerID to find corresponding records.

    Set rst = CurrentDb.OpenRecordset("select * from dbo_Customers
    where dbo_Customers.CustomerID=" & CustomerID, dbOpenDynaset, [dbSeeChanges])


    My question is what would be set rst syntax for a table that has primary key consisting of 2 fields ?

    Thanx

  2. #2
    Join Date
    Feb 2004
    Location
    One Flump in One Place
    Posts
    14,912
    Code:
    Set rst = CurrentDb.OpenRecordset("select * from dbo_Customers 
    where dbo_Customers.CustomerID=" & CustomerID & " AND myTextColumn = '" & TextValue & "'", dbOpenDynaset, [dbSeeChanges])

  3. #3
    Join Date
    Mar 2010
    Posts
    2
    Quote Originally Posted by pootle flump View Post
    Code:
    Set rst = CurrentDb.OpenRecordset("select * from dbo_Customers 
    where dbo_Customers.CustomerID=" & CustomerID & " AND myTextColumn = '" & TextValue & "'", dbOpenDynaset, [dbSeeChanges])

    Thank You. You're fast

Tags for this Thread

Posting Permissions

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