[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 428
  • Last Modified:

Minimize & Exit Command

The minimize and exit command under file pull-down menu not working, please help.

In case wanted to test the program, I have placed the project file (Address Book) under the following shared website. Please download and run it with Visual Basic 6.0

http://www.4shared.com/login.jsp?sessionUnavailable=1

Please login as jagadishnallappan <at>yahoo <dot>com  
Password: abcdef


email address sanitized
angel eyes, zone advisor
0
Jagadishnallappan
Asked:
Jagadishnallappan
  • 3
3 Solutions
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
to minimize:
Private Sub minimize_Click()
  Me.WindowState = vbMinimized
End Sub
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
now, please add this line in your form1 (editor.frm):
Option Explicit

and try to compile. you will get a couple of problems...
0
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
the problem with your "exit" is that it kept the application running, because the frmSearch was used implicitly, this in your "form_load" event:

If frmSearch.txtname.Caption <> "" Then
  Adodc1.Recordset.Find "Name='" & frmSearch.txtname.Caption & "'"
End If

please see how I modified the code slightly to get this changed effectively

Option Explicit

Dim cn As ADODB.Connection
Dim rs As ADODB.Recordset
Dim response As String

Dim lfrmSearch As frmSearch

Private Sub aboutus_Click()
    Dim f As frmAbout
    Set f = New frmAbout
    f.Show vbModal, Me
    Unload f
    Set f = Nothing
End Sub

Private Sub cmdSearch_Click()
  If lfrmSearch Is Nothing Then
    Set lfrmSearch = New frmSearch
  End If
  lfrmSearch.Show vbModeless, Me
End Sub

Private Sub Command1_Click()
Command1.Enabled = False
Command4.Enabled = True
Command2.Enabled = True
Command5.Enabled = True
Command6.Enabled = True
Command7.Enabled = True
Adodc1.Recordset.CancelUpdate
End Sub

Private Sub Command2_Click()
response = MsgBox("Are you Sure to Delete", vbYesNo, "Address Book 1.0")
If response = "6" Then
Adodc1.Recordset.Delete
Adodc1.Recordset.MoveNext
If Adodc1.Recordset.EOF = True Then Adodc1.Recordset.MoveLast
End If
End Sub

Private Sub Command3_Click()
Adodc1.Recordset.Update
Command1.Enabled = False
Command4.Enabled = True
Command2.Enabled = True
Command5.Enabled = True
Command6.Enabled = True
Command7.Enabled = True
End Sub


Private Sub Command4_Click()
Adodc1.Recordset.AddNew
txtname.SetFocus
Command1.Enabled = True
Command4.Enabled = False
Command2.Enabled = False
Command5.Enabled = False
Command6.Enabled = False
Command7.Enabled = False
End Sub

Private Sub Command5_Click()
Unload Me
End Sub

Private Sub Command6_Click()
Adodc1.Recordset.MoveNext
If Adodc1.Recordset.EOF Then Adodc1.Recordset.MoveLast
End Sub

Private Sub Command7_Click()
Adodc1.Recordset.MovePrevious
If Adodc1.Recordset.BOF Then Adodc1.Recordset.MoveFirst
End Sub


Private Sub exit_Click()
  If Not (lfrmSearch Is Nothing) Then
    lfrmSearch.Hide
    Unload lfrmSearch
    Set lfrmSearch = Nothing
  End If
  
  Unload Me
End Sub

Private Sub Form_Load()
  Set lfrmSearch = New frmSearch
  Adodc1.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & App.Path & "\address.mdb;Persist Security Info=False"
  Adodc1.RecordSource = ("SELECT * FROM dir Order By Name")
  Adodc1.Refresh
  If lfrmSearch.txtname.Caption <> "" Then
  Adodc1.Recordset.Find "Name='" & lfrmSearch.txtname.Caption & "'"
  End If
End Sub

Private Sub Form_Unload(Cancel As Integer)
  If Not (lfrmSearch Is Nothing) Then
    lfrmSearch.Adodc1.Refresh
  End If
End Sub

Private Sub howtosearch_Click()
   ' Load frmHowtoSearch
   ' frmHowtoSearch.Show
   MsgBox "You can use our Address Book 1.0 in a very convenient manner, it helps you in maintaining you daily routing contacts. To add contact Just use the Add new button on the Entry Screen. To Update contact just click on the Save and Update Button. To Search contact just click on the Search Contact button on  Entry Screen.", vbOKOnly, "Address Book 1.0"
End Sub

Private Sub minimize_Click()
  Me.WindowState = vbMinimized
End Sub

Private Sub txtname_GotFocus()
'SendKeys "{home}+{end}"
End Sub

Private Sub txtname_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 39 Or KeyCode = 40 Then txtFax.SetFocus
If KeyCode = 37 Or KeyCode = 38 Then Command3.SetFocus
End Sub

Private Sub txtname_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then txtFax.SetFocus
End Sub

Private Sub LastName_GotFocus()
'SendKeys "{home}+{end}"
End Sub

Private Sub txtLastName_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 39 Or KeyCode = 40 Then txtState.SetFocus
If KeyCode = 37 Or KeyCode = 38 Then txtAddress.SetFocus
End Sub

Private Sub txtLastName_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then txtState.SetFocus
End Sub

Private Sub Address_GotFocus()
'SendKeys "{home}+{end}"
End Sub

Private Sub txtAddress_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 39 Or KeyCode = 40 Then txtState.SetFocus
If KeyCode = 37 Or KeyCode = 38 Then txtAddress.SetFocus
End Sub

Private Sub txtAddress_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then txtState.SetFocus
End Sub

Private Sub City_GotFocus()
'SendKeys "{home}+{end}"
End Sub

Private Sub txtCity_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 39 Or KeyCode = 40 Then txtState.SetFocus
If KeyCode = 37 Or KeyCode = 38 Then txtAddress.SetFocus
End Sub

Private Sub txtCity_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then txtState.SetFocus
End Sub

Private Sub State_GotFocus()
'SendKeys "{home}+{end}"
End Sub

Private Sub txtState_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 39 Or KeyCode = 40 Then txtState.SetFocus
If KeyCode = 37 Or KeyCode = 38 Then txtAddress.SetFocus
End Sub

Private Sub txtState_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then txtState.SetFocus
End Sub

Private Sub Country_GotFocus()
'SendKeys "{home}+{end}"
End Sub

Private Sub txtCountry_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 39 Or KeyCode = 40 Then txtState.SetFocus
If KeyCode = 37 Or KeyCode = 38 Then txtAddress.SetFocus
End Sub

Private Sub txtCountry_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then txtState.SetFocus
End Sub

Private Sub txtZipCode_GotFocus()
'SendKeys "{home}+{end}"
End Sub

Private Sub txtZipCode_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 39 Or KeyCode = 40 Then txtState.SetFocus
If KeyCode = 37 Or KeyCode = 38 Then txtAddress.SetFocus
End Sub

Private Sub txtZipCode_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then txtState.SetFocus
End Sub

Private Sub txtCompany_GotFocus()
'SendKeys "{home}+{end}"
End Sub

Private Sub txtCompany_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 39 Or KeyCode = 40 Then txtState.SetFocus
If KeyCode = 37 Or KeyCode = 38 Then txtAddress.SetFocus
End Sub

Private Sub txtCompany_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then txtState.SetFocus
End Sub
Private Sub txtTitle_GotFocus()
'SendKeys "{home}+{end}"
End Sub

Private Sub txtTitle_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 39 Or KeyCode = 40 Then txtFax.SetFocus
If KeyCode = 37 Or KeyCode = 38 Then txtMobilePhone.SetFocus
End Sub

Private Sub txtTitle_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then txtFax.SetFocus
End Sub

Private Sub txtWorkPhone_GotFocus()
'SendKeys "{home}+{end}"
End Sub

Private Sub txtWorkPhone_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 39 Or KeyCode = 40 Then txtFax.SetFocus
If KeyCode = 37 Or KeyCode = 38 Then txtMobilePhone.SetFocus
End Sub

Private Sub txtWorkPhone_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then txtFax.SetFocus
End Sub

Private Sub txtFax_GotFocus()
'SendKeys "{home}+{end}"
End Sub

Private Sub txtFax_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 39 Or KeyCode = 40 Then txtFax.SetFocus
If KeyCode = 37 Or KeyCode = 38 Then txtMobilePhone.SetFocus
End Sub

Private Sub txtFax_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then txtFax.SetFocus
End Sub

Private Sub txtHomePhone_GotFocus()
'SendKeys "{home}+{end}"
End Sub

Private Sub txtHomePhone_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 39 Or KeyCode = 40 Then txtFax.SetFocus
If KeyCode = 37 Or KeyCode = 38 Then txtMobilePhone.SetFocus
End Sub

Private Sub txtHomePhone_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then txtFax.SetFocus
End Sub

Private Sub txtMobilePhone_GotFocus()
'SendKeys "{home}+{end}"
End Sub

Private Sub txtMobilePhone_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 39 Or KeyCode = 40 Then txtFax.SetFocus
If KeyCode = 37 Or KeyCode = 38 Then txtMobilePhone.SetFocus
End Sub

Private Sub txtMobilePhone_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then txtFax.SetFocus
End Sub

Private Sub txtEmail_GotFocus()
'SendKeys "{home}+{end}"
End Sub

Private Sub txtEmail_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 39 Or KeyCode = 40 Then txtFax.SetFocus
If KeyCode = 37 Or KeyCode = 38 Then Command3.SetFocus
End Sub

Private Sub txtEmail_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then txtFax.SetFocus
End Sub

Private Sub txtWeb_GotFocus()
'SendKeys "{home}+{end}"
End Sub

Private Sub txtWeb_KeyDown(KeyCode As Integer, Shift As Integer)
If KeyCode = 39 Or KeyCode = 40 Then Command3.SetFocus
If KeyCode = 37 Or KeyCode = 38 Then txtFax.SetFocus
End Sub

Private Sub txtWeb_KeyPress(KeyAscii As Integer)
If KeyAscii = 13 Then Command3.SetFocus
End Sub

Open in new window

0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now