Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2004

    Unanswered: Subform ID Capture

    Hi there,
    I have writtena system primarily code based, however I seem to be getting stuck on what I presume to be a relatively easy area. I have a main form which is essentially a Tab Control (9 options) called ....frmTabData. Within each of these option I have subforms such as frmProperty, frmBank, frmNextofKin.
    I have written a function to capture the address details relevant to each of theses subforms from a single address form, popAddress. Whichever form I open the address form from writes its name via caption to a lable on add frm.
    My problem is I have written if statements to determine which form is open and hence wrie to appt table, but I cannot see the subform primary key fields. The code will recognise frmTabData but notfrmProperty (underlying subform), here is my code.

    strlabel = frmcurrent("lblsource").Caption

    If strlabel = "Property" Then
    Set dbcurrent = CurrentDb
    Set rstAddress = dbcurrent.OpenRecordset("tblAddress", dbOpenForwardOnly)
    Set frmProperty = Forms("frmProperty")

    'Capt PK Property
    lngPropertyID = frmProperty("txtPropertyID").Value

    'Capture Max ID address
    lngaddressid = DMax("AddressID", "tbladdress", "")

    'Write to link table
    Set rstAddressAdd = dbcurrent.OpenRecordset("lnkPropertyAddress", dbOpenTable)

    With rstAddressAdd
    !propertyID = lngPropertyID
    !addressid = lngaddressid
    End With
    End If

  2. #2
    Join Date
    Apr 2002
    I haven't worked with tabbed forms before but this may still apply. Usually you must reference a field in a subform via the main form and the name of the subform control. Try this:

    'Capt PK Property
    lngPropertyID = frmTabData!(frmProperty subform control name)!txtPropertyID

    Anyone with tabbed form and subforms experience please chime in with any other ideas.

  3. #3
    Join Date
    Apr 2004
    Cheers for this,
    I did try this but still no luck, in the end I have decided to use individual forms. This db is a fairly straightforward one but I am having one of those 'nothing works......ever' days.

    Aesthetically it looks poor but this is a work thing and I dont care if the user thinks it looks ugly, it works.

    Thanks for trying to help.


Posting Permissions

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