Hi,
This si such a simple thing but I can't work out why it's not working. I am wanting to create a directory based on the customer number and name each time the "Add Customer" form is closed.
For some reason, the Me.CustNum and Me.CustName are returning the details for the first record in the CustomerT Table no matter which record I'm on in the form. I must be missing something really simple. The Buttonclick code at the top works fine and checks the current record but the bottom dirpath code doesn't.
The attached code is running on the AddCustomerF Form Close event.
Thanks
This si such a simple thing but I can't work out why it's not working. I am wanting to create a directory based on the customer number and name each time the "Add Customer" form is closed.
For some reason, the Me.CustNum and Me.CustName are returning the details for the first record in the CustomerT Table no matter which record I'm on in the form. I must be missing something really simple. The Buttonclick code at the top works fine and checks the current record but the bottom dirpath code doesn't.
The attached code is running on the AddCustomerF Form Close event.
Code:
Private Sub Form_Close()
Dim ButtonClick
If [Form].Dirty Then
ButtonClick = MsgBox("You have unsaved changes on this form. Would you like to save them?", vbYesNoCancel)
If ButtonClick = vbYes Then
DoCmd.RunCommand acCmdSaveRecord
ElseIf ButtonClick = vbNo Then
DoCmd.RunCommand acCmdUndo
End If
End If
Dim dirpath As String
dirpath = Me.CustomerNumber & " " & Me.CustomerName
Debug.Print dirpath
If Dir("C:\Users\Owner\Documents\Job Management System\Test Database version 2_trial 2\Test\" & dirpath, vbDirectory) = "" Then
MkDir "C:\Users\Owner\Documents\Job Management System\Test Database version 2_trial 2\Test\" & dirpath
End If
End Sub