Unbound form

Bilal

Registered User.
Local time
Today, 04:00
Joined
Sep 30, 2013
Messages
64
has anybody got a data entry unbound form with subform that they can send me, a tripped version of database will be really really helpful :)
i just can not get my unbound form to work
 
or alternatelysomeone has told me that to get my code to work i have to do three things in my tblSave code
1. Save subform table first
2.Get personID from sub form
3.save the master table second
this is my tblSave code

Code:
Private Sub tblSave()
    Dim tmpCN As Double
    Dim newStd As String
    Dim frs As DAO.Recordset
    With rs
        If InMode = "New" Then
            
            
            newStd = "SELECT tblSupplier.PersonID FROM tblSupplier WHERE tblSupplier.SupplierName = " & Chr$(34) & Me.SupplierName.Value & Chr$(34) & " and tblSupplier.Organization = " & Chr$(34) & Me.Organization.Value & Chr$(34) & ";"
            Set db = CurrentDb
            Set frs = db.OpenRecordset(newStd, dbOpenDynaset)
            
            frs.MoveFirst
            PersonIDTemp = frs!PersonID
            'PersonIDTemp = DLookup("[PersonID]", "tblSupplier", "[Organization] = '" & Me.Organization.Value & "' And [SupplierName] = '" & Me.SupplierName.Value & "' And [DOB] = #" & Me.DOB.Value & "#")
            
            Forms!frmSupplier![sfrmPerson].Form![PersonID] = PersonIDTemp
            Me![PersonID] = PersonIDTemp
            
            'Forms!frmSupplier![sfrmPerson].Enabled = True
            'Forms!frmSupplier![sfrmPerson].Form.SetSubAdd
             Forms!frmSupplier![sfrmPerson].Form.SubTableSave
        
            'Save subform table first
            'Get personID from sub form
            'save the master table second
            
                                                                   
            .AddNew
                ![PersonID] = Me.PersonID.Value 'DOUBLE CHECK THIS, NEED SYSTEM TO AUTO ADD PersonID
                ![SupplierName] = Me.SupplierName.Value
                ![State] = Me.State.Value
                ![Organization] = Me.Organization.Value
                ![SupplierID] = Me.SupplierID.Value
               ' Forms!!
            .Update
            
            
            
        ElseIf InMode = "Dirty" Then
            .Edit
                ![Organization] = Me.Organization.Value
                ![SupplierName] = Me.SupplierName.Value
                ![State] = Me.State.Value
            .Update
            
        End If
        
        If .RecordCount = 1 Then
            .MoveLast
            .MoveFirst
        Else
            tmpCN = PersonIDTemp
            .MoveLast
            .MoveFirst
            .FindFirst "[PersonID] = " & tmpCN
            Call cdePopulate
        End If
    End With
    Call FindPosition
End Sub
 

Users who are viewing this thread

Back
Top Bottom