can't execute code in break mode!!

Mayozero

New Member
Joined
May 16, 2021
Messages
18
Office Version
  1. 2016
Platform
  1. Windows
Greetings,
can any1 please help me to fix this code idk what is the wrong but it Says "can't execute code in break mode"
and sometimes when open the form i can't search using the date and sometimes it work please i will insert the full code and please someone help me asap ??
Untitled_2100.jpg


The module code is : ---->
VBA Code:
Option Explicit
Dim Tempo As Date


Sub clock1()
Tempo = Now + TimeValue("00:00:01")
Application.OnTime Tempo, Procedure:="Lable_Text", Schedule:=True
End Sub



Sub Lable_Text()
UserForma.TextBox2.Value = Format(Now, "[$-x-systime]h:mm:ss AM/PM")
Call clock1
End Sub


Sub clock2()
On Error Resume Next
Application.OnTime Tempo, Procedure:="Lable_Text", Schedule:=False
End Sub
and the userform code is : ---->
VBA Code:
Option Explicit
'==================================================
'==================================================
' When UserForma Initialize complete the following;
'-------------------------------------------------------------
Private Sub UserForm_Initialize()
Call items_from_code_to_combobox1
Call show_data_in_listbox_test
Call items_from_database_to_combobox2
Call show_data_in_listbox_Statics_of_the_month
On Error Resume Next
Me.TextBox1 = Format(CDate(Me.TextBox1), "mm/dd/yyyy")
TextBox1.Value = Format(Date, "mm/dd/yyyy") ''' this is the true date format
Application.Run "clock1"
TextBox2.Value = Format(Now, "[$-x-systime]h:mm:ss AM/PM")
Application.Run "clock1"
End Sub
'Private Sub UserForm_QueryClose(Cancel As Integer, CloseMode As Integer)
'clock2
'End Sub
Private Sub TextBox1_AfterUpdate()
On Error Resume Next
Me.TextBox1 = Format(CDate(Me.TextBox1), "dd-mmm-yyyy")
End Sub

'==================================================
'==================================================
' Here are the functions to be called;
'-------------------------------------------------------------
Function items_from_code_to_combobox1()
ComboBox1.AddItem "Normal"
ComboBox1.AddItem "Weekend"
ComboBox1.AddItem "Holiday"
End Function

Function items_from_database_to_combobox2()
Call search_from_form_Into_Bottom_Boxs
Sheets("Database").Activate
Dim lastrow As Long
lastrow = Cells(Rows.Count, "A").End(xlUp).Row
ComboBox2.List = Range("A2:A" & lastrow).Value
End Function
'==================================================
'==================================================
' Here are the Functins for command buttons from frame1;
'-------------------------------------------------------------
Function copy_from_form_without_repeat_LoginB1()
Dim rng1 As Range
Dim str_search As String
str_search = TextBox1.Value
ActiveWorkbook.Sheets("Database").Activate
Set rng1 = Sheets("Database").Range("A:A").Find(str_search, , xlValues, xlWhole)
If rng1 Is Nothing Then
Dim lastrow As Long
lastrow = ActiveWorkbook.Sheets("Database").Range("A1000000").End(xlUp).Row
lastrow = lastrow + 1
With ActiveWorkbook.Sheets("Database")
.Range("A" & lastrow).Value = TextBox1.Value
.Range("B" & lastrow).Value = ComboBox1.Value
.Range("C" & lastrow).Value = TextBox2.Value
End With
Else
MsgBox str_search & "  is already listed"
End If
End Function

Function edit_from_form_LogoutB1()
Dim rng1 As Range
Dim str_search As String
str_search = TextBox1.Value
ActiveWorkbook.Sheets("Database").Activate
Set rng1 = Sheets("Database").Range("A:A").Find(str_search, , xlValues, xlWhole)
If Not rng1 Is Nothing Then
rng1.Select
Dim row_number As Long
row_number = ActiveCell.Row
With ActiveWorkbook.Sheets("Database")
.Range("A" & row_number).Value = .Range("A" & row_number).Value
.Range("B" & row_number).Value = Range("B" & row_number).Value
.Range("C" & row_number).Value = .Range("C" & row_number).Value
.Range("D" & row_number).Value = TextBox2.Value
End With
Else
MsgBox str_search & "Not Found"
End If
End Function

Function edit_from_form_LoginB2()
Dim rng1 As Range
Dim str_search As String
str_search = TextBox1.Value
ActiveWorkbook.Sheets("Database").Activate
Set rng1 = Sheets("Database").Range("A:A").Find(str_search, , xlValues, xlWhole)
If Not rng1 Is Nothing Then
rng1.Select
Dim row_number As Long
row_number = ActiveCell.Row
With ActiveWorkbook.Sheets("Database")
.Range("A" & row_number).Value = .Range("A" & row_number).Value
.Range("B" & row_number).Value = Range("B" & row_number).Value
.Range("C" & row_number).Value = .Range("C" & row_number).Value
.Range("D" & row_number).Value = .Range("D" & row_number).Value
.Range("E" & row_number).Value = TextBox2.Value
End With
Else
MsgBox str_search & "Not Found"
End If
End Function

Function edit_from_form_LogoutB2()
Dim rng1 As Range
Dim str_search As String
str_search = TextBox1.Value
ActiveWorkbook.Sheets("Database").Activate
Set rng1 = Sheets("Database").Range("A:A").Find(str_search, , xlValues, xlWhole)
If Not rng1 Is Nothing Then
rng1.Select
Dim row_number As Long
row_number = ActiveCell.Row
With ActiveWorkbook.Sheets("Database")
.Range("A" & row_number).Value = .Range("A" & row_number).Value
.Range("B" & row_number).Value = Range("B" & row_number).Value
.Range("C" & row_number).Value = .Range("C" & row_number).Value
.Range("D" & row_number).Value = .Range("D" & row_number).Value
.Range("E" & row_number).Value = .Range("E" & row_number).Value
.Range("F" & row_number).Value = TextBox2.Value
End With
Else
MsgBox str_search & "Not Found"
End If
End Function

Function show_data_in_listbox_test()
    Dim lastrow As Long, Row As Long, Col As Long, TempArray
    With Sheets("Database")
        lastrow = .Cells(Rows.Count, "A").End(xlUp).Row
        TempArray = .Range("A1:F" & lastrow).Value
        For Row = 1 To lastrow
            For Col = 3 To 6 '---select.name.for.the.columns; from 3 to 6 with Col= 3:6'
                TempArray(Row, Col) = Format(TempArray(Row, Col), "h:mm:ss")
            Next Col
             TempArray(Row, 2) = Format(TempArray(Row, 2), "mm/dd/yyyy")
        Next Row
    End With
    With ListBox1
        .ColumnCount = 6
        .ColumnWidths = "145,80,75,90,80,80"
        .List = TempArray
    End With
End Function

'Function show_data_in_listbox_Statics_of_the_month_2()
'ListBox2.ColumnCount = 7
'ListBox2.ColumnWidths = "100,100,100,100,100,100,100"
'Sheets("Database").Activate
'Dim lastrow As Long
'lastrow = Cells(Rows.Count, "N").End(xlUp).Row
'ListBox2.List = Range("N1:T" & lastrow).Value
'End Function
Function show_data_in_listbox_Statics_of_the_month()
    Dim lastrow As Long, Row As Long, Col As Long, TempArray
    With Sheets("Database")
        lastrow = .Cells(Rows.Count, "A:A").End(xlUp).Row
        TempArray = .Range("N1:T" & lastrow).Value
        For Row = 1 To 2
            For Col = 1 To 4 '---select.name.for.the.columns; from 3 to 6 with Col= 3:6'
                TempArray(Row, Col) = Format(TempArray(Row, Col), "h:mm:ss")
            Next Col
             'TempArray(Row, 2) = Format(TempArray(Row, 2), "")
        Next Row
    End With
    With ListBox2
        .ColumnCount = 7
        .ColumnWidths = "160,135,135,135,90,90,90"
        .List = TempArray
    End With
End Function
'==================================================
'==================================================
' Here are the 2nd section functions to be called into frame2;
'-------------------------------------------------------------
Sub search_from_form_Into_Bottom_Boxs()
    Dim rng1        As Range
    Dim str_search  As String
    Dim c           As Integer
    Dim row_number  As Long
    Dim wsDatabase  As Worksheet
   
    Set wsDatabase = ThisWorkbook.Sheets("Database")
    str_search = Me.ComboBox2.Value
    If Len(str_search) = 0 Then Exit Sub
   
    Set rng1 = wsDatabase.Range("A:A").Find(str_search, , xlValues, xlWhole)
    If Not rng1 Is Nothing Then
        row_number = rng1.Row
        For c = 2 To 9
            Me.Controls("TextBox" & c + 1).Value = _
            wsDatabase.Cells(row_number, c).Text
        Next c
    Else
        MsgBox str_search & " Not X Found", 48, "Not SS Found"
    End If
End Sub

Function edit_from_form_into_DB_22()
Dim rng1 As Range
Dim str_search As String
str_search = ComboBox2.Value
ActiveWorkbook.Sheets("Database").Activate
Set rng1 = Sheets("Database").Range("A:A").Find(str_search, , xlValues, xlWhole)
If Not rng1 Is Nothing Then
rng1.Select
Dim row_number As Long
row_number = ActiveCell.Row
With ActiveWorkbook.Sheets("Database")
.Range("A" & row_number).Value = .Range("A" & row_number).Value
.Range("B" & row_number).Value = TextBox3.Value
.Range("C" & row_number).Value = TextBox4.Value
.Range("D" & row_number).Value = TextBox5.Value
.Range("E" & row_number).Value = TextBox6.Value
.Range("F" & row_number).Value = TextBox7.Value
.Range("G" & row_number).Value = .Range("G" & row_number).Value
.Range("H" & row_number).Value = .Range("H" & row_number).Value
.Range("I" & row_number).Value = Range("I" & row_number).Value
End With
Else
MsgBox str_search & "Not Found"
End If
End Function

Private Sub CommandButton1_Click()
Call copy_from_form_without_repeat_LoginB1
Call show_data_in_listbox_test
End Sub
Private Sub CommandButton2_Click()
Call edit_from_form_LogoutB1
Call show_data_in_listbox_test
End Sub
Private Sub CommandButton3_Click()
Call edit_from_form_LoginB2
Call show_data_in_listbox_test
End Sub
Private Sub CommandButton4_Click()
Call edit_from_form_LogoutB2
Call show_data_in_listbox_test
End Sub
Private Sub CommandButton5_Click()
Me.Hide
Application.Visible = True
ThisWorkbook.Sheets("Database").Activate
End Sub
Private Sub CommandButton6_Click()
ThisWorkbook.Save
Application.Quit
End Sub
Private Sub CommandButton7_Click()
Call search_from_form_Into_Bottom_Boxs
End Sub
Private Sub CommandButton8_Click()
Call edit_from_form_into_DB_22
Call show_data_in_listbox_test
End Sub


and this workbook code is : ---->
VBA Code:
Option Explicit
Private Sub Workbook_Open()
Application.Visible = False
UserForma.Show
End Sub
 

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Forum statistics

Threads
1,213,546
Messages
6,114,251
Members
448,556
Latest member
peterhess2002

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top