Alarm problem

K

Kay

Hi

I have created an alarm clock in access 2000 where a user can set upto
5 alarms. I have used label1 at the current time. I have 3 textboxes
(alarm time, date, message). And 3buttons(hide form, cancel all alarms,
save alarm). I am getting an error with the following to start with

Private Sub Form_Load()
Text1.Text = Time
Text2.Text = Date
error - you can't reference a property or method for a control unless
the control has focus



my code is as follows:

Dim AlarmSetting1 As String
Dim AlarmSetting2 As String
Dim AlarmSetting3 As String
Dim AlarmSetting4 As String
Dim AlarmSetting5 As String

Dim AlarmMessage1 As String
Dim AlarmMessage2 As String
Dim AlarmMessage3 As String
Dim AlarmMessage4 As String
Dim AlarmMessage5 As String

Private Sub Command1_Click()
Me.Visible = False
End Sub

Private Sub Command2_Click()
SaveSetting "AlarmClock", "Setting", "Alarm1", "0"
SaveSetting "AlarmClock", "Setting", "Alarm2", "0"
SaveSetting "AlarmClock", "Setting", "Alarm3", "0"
SaveSetting "AlarmClock", "Setting", "Alarm4", "0"
SaveSetting "AlarmClock", "Setting", "Alarm5", "0"
End Sub


Private Sub Command3_Click()

If AlarmSetting1 = "0" Then
SaveSetting "AlarmClock", "Setting", "Alarm1", Text1.Text &
Text2.Text
SaveSetting "AlarmClock", "Setting", "Message1", Text3.Text
ElseIf AlarmSetting2 = "0" Then
SaveSetting "AlarmClock", "Setting", "Alarm2", Text1.Text &
Text2.Text
SaveSetting "AlarmClock", "Setting", "Message2", Text3.Text
ElseIf AlarmSetting3 = "0" Then
SaveSetting "AlarmClock", "Setting", "Alarm3", Text1.Text &
Text2.Text
SaveSetting "AlarmClock", "Setting", "Message3", Text3.Text
ElseIf AlarmSetting4 = "0" Then
SaveSetting "AlarmClock", "Setting", "Alarm4", Text1.Text &
Text2.Text
SaveSetting "AlarmClock", "Setting", "Message4", Text3.Text
ElseIf AlarmSetting5 = "0" Then
SaveSetting "AlarmClock", "Setting", "Alarm5", Text1.Text &
Text2.Text
SaveSetting "AlarmClock", "Setting", "Message5", Text3.Text
Else
MsgBox "I'm Sorry All Alarm Slots Are Full"
End If

End Sub


Private Sub Form_Load()
Text1.Text = Time
Text2.Text = Date
AlarmClock.BackColor = vbBlack
Label1.BackColor = vbBlack
Label2.BackColor = vbBlack
Label3.BackColor = vbBlack
Label1.ForeColor = vbYellow
Label2.ForeColor = vbYellow
Label3.ForeColor = vbYellow

Command1.Caption = "Hide Me"
Command2.Caption = "Clear all Entries"
Command3.Caption = "OK"
Me.Caption = "Alarm Clock"

AlarmSetting1 = GetSetting("AlarmClock", "Setting", "Alarm1", "0")
AlarmSetting2 = GetSetting("AlarmClock", "Setting", "Alarm2", "0")
AlarmSetting3 = GetSetting("AlarmClock", "Setting", "Alarm3", "0")
AlarmSetting4 = GetSetting("AlarmClock", "Setting", "Alarm4", "0")
AlarmSetting5 = GetSetting("AlarmClock", "Setting", "Alarm5", "0")

AlarmMessage1 = GetSetting("AlarmClock", "Setting", "Message1", "0")
AlarmMessage2 = GetSetting("AlarmClock", "Setting", "Message2", "0")
AlarmMessage3 = GetSetting("AlarmClock", "Setting", "Message3", "0")
AlarmMessage4 = GetSetting("AlarmClock", "Setting", "Message4", "0")
AlarmMessage5 = GetSetting("AlarmClock", "Setting", "Message5", "0")
End Sub

Private Sub Form_Timer()
Label1.Caption = Time & vbCrLf & Date

AlarmSetting1 = GetSetting("AlarmClock", "Setting", "Alarm1", "0")
AlarmSetting2 = GetSetting("AlarmClock", "Setting", "Alarm2", "0")
AlarmSetting3 = GetSetting("AlarmClock", "Setting", "Alarm3", "0")
AlarmSetting4 = GetSetting("AlarmClock", "Setting", "Alarm4", "0")
AlarmSetting5 = GetSetting("AlarmClock", "Setting", "Alarm5", "0")

AlarmMessage1 = GetSetting("AlarmClock", "Setting", "Message1", "0")
AlarmMessage2 = GetSetting("AlarmClock", "Setting", "Message2", "0")
AlarmMessage3 = GetSetting("AlarmClock", "Setting", "Message3", "0")
AlarmMessage4 = GetSetting("AlarmClock", "Setting", "Message4", "0")
AlarmMessage5 = GetSetting("AlarmClock", "Setting", "Message5", "0")


If Time = AlarmSetting1 Then
Beep
MsgBox AlarmMessage1
Me.Visible = True
ElseIf Time & Date = AlarmSetting2 Then
Beep
MsgBox AlarmMessage2
Me.Visible = True
ElseIf Time & Date = AlarmSetting3 Then
Beep
MsgBox AlarmMessage3
Me.Visible = True
ElseIf Time & Date = AlarmSetting4 Then
Beep
MsgBox AlarmMessage4
Me.Visible = True
ElseIf Time & Date = AlarmSetting5 Then
Beep
MsgBox AlarmMessage5
Me.Visible = True
End If

End Sub

Any help will be much appreciated
 
K

Klatuu

You can only use the Text property of a control when it has the focus. In
Access, it is seldom necessary to use the Text property. All you really need
is:
Me.Text1 = Time
Me.Text2 = Date
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top