Results 1 to 2 of 2
  1. #1
    ramindya is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2012
    Posts
    20

    Beforeinsert syntax

    There are three tables in SQL server - Patient, TableA and TableB.
    Table A has ID which is primary key, visit number and MRN ( foreign key ).The fields are displayed in a subfrmTableA embedded in the Mainfrm
    Patient has MRN as the Primary Key. The fields are displayed in Mainfrm
    TableB has ID which is primary key, visit number and MRN ( foreign key ) and someother fields. The fields are displayed in a form frmTableB which is called by a button click event from subfrmTableA



    The following code increments the Visitnumber for each patient in the TableA and I want the same visitnumber to be tranfered in the visitnumber field of TableB.

    What is the VBA code for that ? This code works perfectly but only inserts in TableA.

    Private Sub Form_BeforeInsert(Cancel As Integer)
    Me.VisitNumber = Nz(DMax("[VisitNumber]", "dbo_tblScheduling", "[MRN] =" & [Forms]![frmMainBase]![MRN]) + 1, 1)
    End Sub

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Duplicate posting is frowned upon.
    https://www.accessforums.net/program...ert-21900.html

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

Similar Threads

  1. Help with syntax
    By accesskid in forum Forms
    Replies: 3
    Last Post: 06-02-2011, 05:14 AM
  2. SQL syntax
    By jgelpi16 in forum Programming
    Replies: 2
    Last Post: 05-04-2011, 08:32 AM
  3. SQL syntax
    By dssrun in forum Queries
    Replies: 4
    Last Post: 04-15-2011, 01:06 PM
  4. Incomplete Syntax Clause (syntax error)
    By ajetrumpet in forum Programming
    Replies: 4
    Last Post: 09-11-2010, 10:47 AM
  5. Please help SQL Syntax
    By jordanturner in forum Access
    Replies: 4
    Last Post: 09-02-2010, 08:05 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