Click here to Skip to main content
15,886,783 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: Georeferencing Pin
OriginalGriff7-Aug-20 20:51
mveOriginalGriff7-Aug-20 20:51 
AnswerRe: Georeferencing Pin
Richard MacCutchan7-Aug-20 21:51
mveRichard MacCutchan7-Aug-20 21:51 
AnswerRe: Georeferencing Pin
Eddy Vluggen22-Aug-20 10:09
professionalEddy Vluggen22-Aug-20 10:09 
QuestionFile System Watcher for remote folders? Pin
ForeverSoftware6-Aug-20 3:47
ForeverSoftware6-Aug-20 3:47 
AnswerRe: File System Watcher for remote folders? Pin
Richard Deeming6-Aug-20 4:00
mveRichard Deeming6-Aug-20 4:00 
QuestionRunning VBA in Shared Mailboxes 365 Pin
Willie_n5-Aug-20 23:20
Willie_n5-Aug-20 23:20 
AnswerRe: Running VBA in Shared Mailboxes 365 Pin
CHill6014-Aug-20 1:38
mveCHill6014-Aug-20 1:38 
QuestionBizarre problem with VBA in an Access Form Pin
Peter R. Fletcher16-Jul-20 12:03
Peter R. Fletcher16-Jul-20 12:03 
I am calling Form_BeforeUpdate directly from a Close (Form) button's onClick Event, to handle various circumstances when the form is only partially filled in but the User wants to bail out. Under certain (perfectly feasible) circumstances, Form_BeforeUpdate is correctly setting Cancel to True within itself, but it is not being passed back to the calling Sub! Subroutine parameters are ByRef by default, but setting Cancel explicitly to ByRef in the definition of Form_BeforeUpdate does not change the misbehavior. Here are the two Subs:
Private Sub cmdClose_Click()
    Dim Cancel As Integer
    Form_BeforeUpdate (Cancel)
    If Cancel Then
        If MsgBox("This record contains errors. Do you wish to correct them before closing the form?", vbYesNo, "Errors") = vbYes Then
            Exit Sub
        Else
            If Me.NewRecord Then
                MsgBox "The current record will be discarded.", vbInformation
            Else
                MsgBox "Any changes made to the current record will be discarded.", vbInformation
            End If
            Me.Undo
        End If
    End If
    blMayClose = True
    DoCmd.Close acForm, Me.Name
End Sub

Private Sub Form_BeforeUpdate(Cancel As Integer)
    Dim rst As New ADODB.Recordset
    
    If Me.NewRecord Then Contact_Pt = lbxContacts.Value
    
    Set rst = New ADODB.Recordset
    rst.Open "SELECT ID FROM Assets WHERE package_Pt = " & ID, CurrentProject.Connection, adOpenStatic, adLockReadOnly
    If Not (rst.EOF And rst.BOF) Then
        If IsNull(Start_Date.Value) Or IsNull(End_Date.Value) Then 'this is where Cancel gets set to True
            MsgBox "You must enter start and end dates for the package before saving it.", vbExclamation, "Dates Missing"
            Cancel = True
        ElseIf End_Date.Value <= Start_Date.Value Then
            MsgBox "The end date must be after the start date.", vbExclamation, "Invalid dates"
            Cancel = True
        End If
    End If
    rst.Close
    Set rst = Nothing
    
End Sub

AnswerRe: Bizarre problem with VBA in an Access Form Pin
CHill6020-Jul-20 5:30
mveCHill6020-Jul-20 5:30 
AnswerRe: Bizarre problem with VBA in an Access Form Pin
CHill6020-Jul-20 5:44
mveCHill6020-Jul-20 5:44 
GeneralRe: Bizarre problem with VBA in an Access Form Pin
Peter R. Fletcher20-Jul-20 7:43
Peter R. Fletcher20-Jul-20 7:43 
GeneralRe: Bizarre problem with VBA in an Access Form Pin
Dave Kreskowiak20-Jul-20 7:59
mveDave Kreskowiak20-Jul-20 7:59 
GeneralRe: Bizarre problem with VBA in an Access Form Pin
CHill6021-Jul-20 2:21
mveCHill6021-Jul-20 2:21 
GeneralRe: Bizarre problem with VBA in an Access Form Pin
Dave Kreskowiak21-Jul-20 5:00
mveDave Kreskowiak21-Jul-20 5:00 
GeneralRe: Bizarre problem with VBA in an Access Form Pin
CHill6021-Jul-20 5:07
mveCHill6021-Jul-20 5:07 
QuestionVB Script Using Com Interface with Out String Pointer Pin
Thomas Andreas Kocher9-Jul-20 23:40
Thomas Andreas Kocher9-Jul-20 23:40 
AnswerRe: VB Script Using Com Interface with Out String Pointer Pin
Dave Kreskowiak12-Jul-20 14:45
mveDave Kreskowiak12-Jul-20 14:45 
QuestionHow to get one I have multiple objects of the same type at run time with VB 2010 Pin
Member 1487052122-Jun-20 18:01
Member 1487052122-Jun-20 18:01 
AnswerRe: How to get one I have multiple objects of the same type at run time with VB 2010 Pin
Dave Kreskowiak23-Jun-20 13:55
mveDave Kreskowiak23-Jun-20 13:55 
AnswerRe: How to get one I have multiple objects of the same type at run time with VB 2010 Pin
Ralf Meier23-Jun-20 20:47
mveRalf Meier23-Jun-20 20:47 
AnswerRe: How to get one I have multiple objects of the same type at run time with VB 2010 Pin
Member 1487052124-Jun-20 3:54
Member 1487052124-Jun-20 3:54 
GeneralRe: How to get one I have multiple objects of the same type at run time with VB 2010 Pin
Richard MacCutchan24-Jun-20 4:27
mveRichard MacCutchan24-Jun-20 4:27 
GeneralRe: How to get one I have multiple objects of the same type at run time with VB 2010 Pin
Dave Kreskowiak24-Jun-20 7:02
mveDave Kreskowiak24-Jun-20 7:02 
GeneralRe: How to get one I have multiple objects of the same type at run time with VB 2010 Pin
Ralf Meier24-Jun-20 19:55
mveRalf Meier24-Jun-20 19:55 
GeneralRe: How to get one I have multiple objects of the same type at run time with VB 2010 Pin
Gerry Schmitz25-Jun-20 3:44
mveGerry Schmitz25-Jun-20 3:44 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.