Question : Access Forms

Using a Cmd Button on a from I want the user to be able to duplicate the current record on the form and then open an additional form to be able to modify the data.  The code I have attached is creating the new record in the table, however when the DoCMd opens the additional form but the latest record created is not displayed.

The table is tblprovidersbill
ProviderBillID is the PK
Current form where USER selects to create the new record is:  frmproviders
Form to be open with newly created record is frmProviders_Recon

Private Sub cmdRECON_Click()

'On Error GoTo Err_Handler
    'Purpose:   Duplicate the main form record and related records in the subform.
    Dim strSql As String    'SQL statement.
    Dim lngID As Long       'Primary key value of the new record.
   
    'Save any edits first
    If Me.Dirty Then
        Me.Dirty = False
    End If
   
    'Make sure there is a record to duplicate.
    If Me.NewRecord Then
        MsgBox "Select the record to duplicate."
    Else
        'Duplicate the main record: add to form's clone.
        With Me.RecordsetClone
            .AddNew
                !ClaimId = Me.ClaimId
                !ProviderID = Me.ProviderID
                !DateofService = Me.DateofService
            'etc for other fields.
            .Update
           
            'Save the primary key value, to use as the foreign key for the related records.
            .Bookmark = .LastModified
            lngID = !ProviderBillID

DoCmd.OpenForm "frmProviders_recon", , , "[providerbillId]= " & DMax("providerbillId", "tblProvidersbill")
End With
End If
End Sub

Answer : Access Forms

Hi learningunix,

the line checks if the left-most byte of 'num' is '1'.

'&num' is a pointer to the memory address where the first byte of 'num' resides. The '(char*)' casts this pointer '&num' (which is a pointer to int) to a pointer to char. Since char is a one byte data type accessing that 'pointer to char' with '*' accesses the first byte of the int. In little endian this byte has to be '1' for and 'int' which is '1' - in big endian the first byte would be '0' since the least significant byte is the most right one ...

Hope that helps,

ZOPPO

Random Solutions  
 
programming4us programming4us