D
d9pierce
Hi,
I have started a db (new to access I may add) One my main form I have
the following code. This works very well witht he exception to the
second from the last private sub and I am working on that. I have on
this form a listbox populated by a qry. All works fine unil I try to
put the second section of code in it delivers a compile error. This
error is on the un_load and I was wondering if there is a way to
combine this code so both applications owrk? The first protects data
from being edited without confirmation and the second is code to allow
me to resize my columns on my list box? This second is also connected
to a module. Both functions work well separate, but not togeither.
Any Suggestions, PLEASE!
Option Compare Database
Option Explicit
Private boolFrmDirty As Boolean
Private boolFrmSaved As Boolean
Private Sub Form_AfterDelConfirm(Status As Integer)
If Me.Saved = False Then Me.Saved = (Status = acDeleteOK)
End Sub
Private Sub Form_AfterUpdate()
Me.Saved = True
End Sub
Private Sub Form_Delete(Cancel As Integer)
If Me.Dirtied = False Then DBEngine.BeginTrans
Me.Dirtied = True
End Sub
Private Sub Form_Dirty(Cancel As Integer)
If Me.Dirtied = False Then DBEngine.BeginTrans
Me.Dirtied = True
End Sub
Private Sub Form_Open(Cancel As Integer)
Dim db As DAO.Database 'DAO
Dim rs As DAO.Recordset 'DOA
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT * FROM Tbl_Contacts",
dbOpenDynaset)
Set Me.Recordset = rs
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim msg As Integer
If Me.Saved Then
msg = MsgBox("Do you want to commit all changes?", vbYesNoCancel)
Select Case msg
Case vbYes
DBEngine.CommitTrans
Case vbNo
DBEngine.Rollback
Case vbCancel
Cancel = True
End Select
Else
If Me.Dirtied Then DBEngine.Rollback
End If
End Sub
Public Property Get Dirtied() As Boolean
Dirtied = boolFrmDirty
End Property
Public Property Let Dirtied(boolFrmDirtyIn As Boolean)
boolFrmDirty = boolFrmDirtyIn
End Property
Public Property Get Saved() As Boolean
Saved = boolFrmSaved
End Property
Public Property Let Saved(boolFrmSavedIn As Boolean)
boolFrmSaved = boolFrmSavedIn
End Property
Private Sub List64_DblClick(Cancel As Integer)
DoCmd.OpenForm "Frm_Contact_Main", , , _
"ContactID = " = Me.List64
End Sub
Private Sub Form_Current()
Me.List64.Requery
End Sub
SECOND:
' Declare a var of type our Resizing class
Private ColReSize As clsResizeColumns
Private Sub Form_Load()
' Create a new instance of our class
Set ColReSize = New clsResizeColumns
' We must tell the Class which control
' we want to work with.
ColReSize.SetListBox Me.List4
' Turn on our flag to allow reszing
ColReSize.AllowResizing = True
' Set our Form size
DoCmd.MoveSize 0, 0, 7925, 5700
End Sub
Private Sub Form_Unload(Cancel As Integer)
' Release the reference to our class
Set ColReSize = Nothing
End Sub
I have started a db (new to access I may add) One my main form I have
the following code. This works very well witht he exception to the
second from the last private sub and I am working on that. I have on
this form a listbox populated by a qry. All works fine unil I try to
put the second section of code in it delivers a compile error. This
error is on the un_load and I was wondering if there is a way to
combine this code so both applications owrk? The first protects data
from being edited without confirmation and the second is code to allow
me to resize my columns on my list box? This second is also connected
to a module. Both functions work well separate, but not togeither.
Any Suggestions, PLEASE!
Option Compare Database
Option Explicit
Private boolFrmDirty As Boolean
Private boolFrmSaved As Boolean
Private Sub Form_AfterDelConfirm(Status As Integer)
If Me.Saved = False Then Me.Saved = (Status = acDeleteOK)
End Sub
Private Sub Form_AfterUpdate()
Me.Saved = True
End Sub
Private Sub Form_Delete(Cancel As Integer)
If Me.Dirtied = False Then DBEngine.BeginTrans
Me.Dirtied = True
End Sub
Private Sub Form_Dirty(Cancel As Integer)
If Me.Dirtied = False Then DBEngine.BeginTrans
Me.Dirtied = True
End Sub
Private Sub Form_Open(Cancel As Integer)
Dim db As DAO.Database 'DAO
Dim rs As DAO.Recordset 'DOA
Set db = CurrentDb
Set rs = db.OpenRecordset("SELECT * FROM Tbl_Contacts",
dbOpenDynaset)
Set Me.Recordset = rs
End Sub
Private Sub Form_Unload(Cancel As Integer)
Dim msg As Integer
If Me.Saved Then
msg = MsgBox("Do you want to commit all changes?", vbYesNoCancel)
Select Case msg
Case vbYes
DBEngine.CommitTrans
Case vbNo
DBEngine.Rollback
Case vbCancel
Cancel = True
End Select
Else
If Me.Dirtied Then DBEngine.Rollback
End If
End Sub
Public Property Get Dirtied() As Boolean
Dirtied = boolFrmDirty
End Property
Public Property Let Dirtied(boolFrmDirtyIn As Boolean)
boolFrmDirty = boolFrmDirtyIn
End Property
Public Property Get Saved() As Boolean
Saved = boolFrmSaved
End Property
Public Property Let Saved(boolFrmSavedIn As Boolean)
boolFrmSaved = boolFrmSavedIn
End Property
Private Sub List64_DblClick(Cancel As Integer)
DoCmd.OpenForm "Frm_Contact_Main", , , _
"ContactID = " = Me.List64
End Sub
Private Sub Form_Current()
Me.List64.Requery
End Sub
SECOND:
' Declare a var of type our Resizing class
Private ColReSize As clsResizeColumns
Private Sub Form_Load()
' Create a new instance of our class
Set ColReSize = New clsResizeColumns
' We must tell the Class which control
' we want to work with.
ColReSize.SetListBox Me.List4
' Turn on our flag to allow reszing
ColReSize.AllowResizing = True
' Set our Form size
DoCmd.MoveSize 0, 0, 7925, 5700
End Sub
Private Sub Form_Unload(Cancel As Integer)
' Release the reference to our class
Set ColReSize = Nothing
End Sub