Mouse Control - drag/drop

shafara7

Registered User.
Local time
Today, 10:12
Joined
May 8, 2017
Messages
118
Hi, I have a form which looks like a weekly calendar (from Monday to Friday) and the Record is shown according to the date it was assigned.
There is a function on that form where I can drag and drop the Record from one day to the other.
The function works well with no error, but then I duplicated the form because we are combining data from two different locations.
The original Form is named frmRunde and the duplicated one is frmRundeMUC.
The only problem here is that the drag and drop function does not work on the second form. It is due to the VBA code in modMaussteureung (modeMouseControl) because there is a section where the form is updated.
Below is the code for that section:
Code:
Public Sub updateMessauftrag(ByVal pMA As Long, ByVal pDate As Date, Optional ByVal pAnlage As Long = 0)
    Dim rs As DAO.Recordset
    Set rs = CurrentDb.OpenRecordset("SELECT * FROM qryEinordnungMA WHERE lngMessauftragNr = " & pMA & ";")
    [COLOR="lime"]'Dates[/COLOR]
    If (rs!indMessaufgabe <= 2) Then 'Analysemessung muss zunächst abgefangen werden, da sons Null-Fehler durch Leeres datEinarbeitIst
        CurrentDb.Execute "UPDATE tblMessauftrag SET datMessungSoll = #" & datConvert(pDate) & "# WHERE lngMessauftragNr = " & pMA & ";"
    ElseIf arbeitstageAddieren(rs!datEinarbeitIst, getKPI("Messung", False)) = pDate Then
        CurrentDb.Execute "UPDATE tblMessauftrag SET datMessungSoll = NULL WHERE lngMessauftragNr = " & pMA & ";"
    Else
        CurrentDb.Execute "UPDATE tblMessauftrag SET datMessungSoll = #" & datConvert(pDate) & "# WHERE lngMessauftragNr = " & pMA & ";"
    End If
    [COLOR="Lime"]'Measuring Equipment[/COLOR]
    If (pAnlage <> 0) Then
        If (rs!indEMMessanlage = pAnlage) Then
            CurrentDb.Execute "UPDATE tblMessauftrag SET indAbweichendeMessanlage = NULL, indAbweichenderMessraum = NULL WHERE lngMessauftragNr = " & pMA & ";"
        Else
            CurrentDb.Execute "UPDATE tblMessauftrag SET indAbweichendeMessanlage = " & pAnlage & ", indAbweichenderMessraum = " & DLookup("indMessraum", "tblMessanlage", "ID = " & pAnlage) & " WHERE lngMessauftragNr = " & pMA & ";"
        End If
    End If
    
    [COLOR="Yellow"]Forms!frmRunde.requerySubforms[/COLOR]
    [COLOR="Red"]Forms!frmRundeMUC.requerySubforms[/COLOR]
End Sub

At first when I tried to drag the record on frmRundeMUC, the error pop-up with the code in Yellow.
Then I added the other line in Red, but it then says the "Forms!frmRunde.requerySubforms" cannot be found.
Does it means that I can't put the Forms!frm___.requerySubforms sumultaneously together?

Sorry if the codes give you headache because it is in German.
 
If thus isasubform the syntax woud be:
Forms!frmRunde!requerySubforms.Form.RequeryReuery

Or maybe a function or sub which you need also to copy from the originaloriginal form.
 
Thank you for your reply.
But I was wondering if the that you have writte is correct, because the 'Requery' at the end is doubled. Is that normal?
 
I believe the code you posted is from a separate module. If that is the case, then youllyoull need to know which form's requerysubforms to execute. Rember that aside from original form, the secind form call this sub whn you do the drag an drop.. You can modify the code by adding a form variable, then executing the requerysubform:

dim frm as form
Set frm=screen.activeform
Frm.requerySubforms
Set frm=nothing
 
I have found the solution. I just need to clarify which form is open at the time of execution.
So I changed the codes..

Forms!frmRunde.requerySubforms
Forms!frmRundeMUC.requerySubforms


to

If CurrentProject.AllForms("frmRunde").IsLoaded Then
Forms!frmRunde.requerySubforms
End If

If CurrentProject.AllForms("frmRundeMUC").IsLoaded Then
Forms!frmRundeMUC.requerySubforms
End If
 
Nice&#55357;&#56832;
And will work even when both forms are open.
 

Users who are viewing this thread

Back
Top Bottom