popup form loses control (1 Viewer)

John Sh

Member
Local time
Tomorrow, 04:11
Joined
Feb 8, 2021
Messages
167
This might be a bit convoluted!
I have a form with a combo box that is controlled by a table/query.
The combo box is set to limit to list. On occasions it is necessary to add an item to the list and this requires a supervisor to ok the addition.
To that end I have used the "on not in list" event to open a small supervisor check in form.
The form opens but control is immediately transferred to the calling sub and the whole thing locks up.
I can input a name and password to the check in form and alternate between the name and password controls but that's it
The check in form is a very slightly modified version of a fully functional log in form .
Is this happening because I am ceiling one form from another and both are open.
I cannot use a subform as there is no relationship possible between the two.

This code works but without any supervisor input
Code:
Private Sub cboEpithet_NotInList(newdata As String, response As Integer)
    Dim rst As DAO.Recordset
    strAnswer = "yes"
'    DoCmd.OpenForm "frmNoList"
    If strAnswer = "yes" Then
        Set rst = CurrentDb.OpenRecordset("species")
        With rst
            .AddNew
            .Fields("Species") = newdata
            .Update
        End With
        rst.Close
        Set rst = Nothing
        response = acDataErrAdded
    Else
        response = acDataErrContinue
        Me.cboEpithet = ""
    End If
End Sub

This code opens the new form and the hangs at the "if stranswer" line
Code:
Private Sub cboEpithet_NotInList(newdata As String, response As Integer)
    Dim rst As DAO.Recordset
    strAnswer = newdata
    DoCmd.OpenForm "frmNoList"
    If strAnswer = "yes" Then
        Set rst = CurrentDb.OpenRecordset("species")
        With rst
            .AddNew
            .Fields("Species") = newdata
            .Update
        End With
        rst.Close
        Set rst = Nothing
        response = acDataErrAdded
    Else
        response = acDataErrContinue
        Me.cboEpithet = ""
    End If
End Sub

And this is the code for the check in form
Code:
Option Compare Database
Option Explicit

Private Sub Form_Current()
    Me.cboLogin.SetFocus
End Sub

Private Sub cboLogin_Click()
    Me.lblNoPass.Visible = False
    If Me.cboLogin = "Student" Then
        strLogin = "A student"
        intLevel = 3
        DoCmd.Close acForm, Me.Name
    End If
End Sub

Private Sub cboLogin_AfterUpdate()
    Me.txtPassword.SetFocus
End Sub

Private Sub txtPassword_AfterUpdate()
    Dim rs As Recordset
    Dim num As Integer
    Me.lblNoPass.Visible = False
    Set rs = CurrentDb.OpenRecordset("login", dbOpenSnapshot, dbReadOnly)
    rs.FindFirst "First = '" & Me.cboLogin & "'"
    intLevel = rs!Level
    strLogin = rs!First
    strFullName = Trim(rs!Last) & ". " & Left(rs!First, 1) & "."
    If Me.txtPassword = Null Or Me.txtPassword = "" Then
        Me.lblNoPass.Visible = True
        GoTo Cleanup
    End If
    num = StrComp(rs!Password, Me.txtPassword, 0)
    If num <> 0 Then
        Me.lblNoPass.Visible = True
        GoTo Cleanup
    End If
    Me.lblNoPass.Visible = False
    strAnswer = "yes"
    DoCmd.Close acForm, Me.Name
Exit Sub
Cleanup:
    Me.cboLogin = ""
    Me.txtPassword = ""
    Me.cboLogin.SetFocus
End Sub
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 02:11
Joined
May 7, 2009
Messages
16,394
you need to open frmNoList as Dialog:

Docmd.OpenForm FormName:="frmNoList", WindowMode:=acDialog
 

John Sh

Member
Local time
Tomorrow, 04:11
Joined
Feb 8, 2021
Messages
167
you need to open frmNoList as Dialog:

Docmd.OpenForm FormName:="frmNoList", WindowMode:=acDialog
Once again I thank you for the quick and spot on reply.
John
 

Users who are viewing this thread

Top Bottom