This is illogical...

S

Stapes

Hi

I have the following code in my Form_Current procedure. I have put
breahpoints in it to try and discover why the error message is coming
out twice. After executing the Exit Sub line, it continues processing
from line 12!! If I remove the statement lines 10-12, it goes to line
7. Help. What is happening?

1 Private Sub Form_Current()
2 On Error GoTo Form_Current_Err
3
4 RecCount = Me.Recordset.RecordCount
5 Dim lngRed As Long, lngWhite As Long
6
7 lngRed = RGB(255, 0, 0)
8 lngWhite = RGB(255, 255, 255)
9
10 If IsNull([BalanceDue]) Or [BalanceDue] = 0 Then
11 [BalanceDue] = DateAdd("ww", -8, [DateOfArrival])
12 End If
13
14 If [BalanceDue] < Date And [Balance] <> 0 Then
15 [BalanceDue].BackColor = lngRed
16 Else
17 [BalanceDue].BackColor = lngWhite
18 End If
19
20 If Deposit < (RentalAmount / 3) - 0.01 And FullPayment <>
RentalAmount Then
21 MsgBox "Warning: Deposit " & Deposit & " is less than 1/3rd of
Rental Amount. Deposit should be at least " & Format(RentalAmount / 3
- 0.01, "$###0.00")
22 End If
23
24 Form_Current_Exit:
25 Exit Sub
26 Form_Current_Err:
27 MsgBox Err.Number & ":" & Err.Description
28 End Sub

Stapes
 
A

Allen Browne

In some circumstances, Form_Current can fire multiple times for the same
record.

If the code is actully going haywire, a decompile might help. To decompile
make a copy of the database, and enter something like this at the command
prompt while Access is not running. It is all one line, and include the
quotes:
"c:\Program Files\Microsoft office\office\msaccess.exe" /decompile
"c:\MyPath\MyDatabase.mdb"
 
S

Stapes

In some circumstances, Form_Current can fire multiple times for the same
record.

If the code is actully going haywire, a decompile might help. To decompile
make a copy of the database, and enter something like this at the command
prompt while Access is not running. It is all one line, and include the
quotes:
"c:\Program Files\Microsoft office\office\msaccess.exe" /decompile
"c:\MyPath\MyDatabase.mdb"

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users -http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.






I have the following code in my Form_Current procedure. I have put
breahpoints in it to try and discover why the error message is coming
out twice. After executing the Exit Sub line, it continues processing
from line 12!! If I remove the statement lines 10-12, it goes to line
7. Help. What is happening?
1 Private Sub Form_Current()
2 On Error GoTo Form_Current_Err
3
4 RecCount = Me.Recordset.RecordCount
5 Dim lngRed As Long, lngWhite As Long
6
7 lngRed = RGB(255, 0, 0)
8 lngWhite = RGB(255, 255, 255)
9
10 If IsNull([BalanceDue]) Or [BalanceDue] = 0 Then
11 [BalanceDue] = DateAdd("ww", -8, [DateOfArrival])
12 End If
13
14 If [BalanceDue] < Date And [Balance] <> 0 Then
15 [BalanceDue].BackColor = lngRed
16 Else
17 [BalanceDue].BackColor = lngWhite
18 End If
19
20 If Deposit < (RentalAmount / 3) - 0.01 And FullPayment <>
RentalAmount Then
21 MsgBox "Warning: Deposit " & Deposit & " is less than 1/3rd of
Rental Amount. Deposit should be at least " & Format(RentalAmount / 3
- 0.01, "$###0.00")
22 End If
23
24 Form_Current_Exit:
25 Exit Sub
26 Form_Current_Err:
27 MsgBox Err.Number & ":" & Err.Description
28 End Sub
Stapes- Hide quoted text -

- Show quoted text -

Hi

Thanks for that. It didn't work, How bizarre. You expect these things
to follow a logical sequence - and they don't. My faith is shattered.
Is this a bug in Access 2003? You say that the form-current section
can fire twice. Why is this, and can it be prevented?

Stapes
 
A

Allen Browne

You cannot prevent the event firing multiple times.

This occurs in any version since Access 2000. (Historically, I suspect it
traces back to the way that MS fixed the bookmark bug.)

You can't prevent it, but you can probably work around it easily enough.
Depends on why you are doing what you are doing, i.e. what you have to
achieve.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Stapes said:
In some circumstances, Form_Current can fire multiple times for the same
record.

If the code is actully going haywire, a decompile might help. To
decompile
make a copy of the database, and enter something like this at the command
prompt while Access is not running. It is all one line, and include the
quotes:
"c:\Program Files\Microsoft office\office\msaccess.exe" /decompile
"c:\MyPath\MyDatabase.mdb"

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users -http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.


I have the following code in my Form_Current procedure. I have put
breahpoints in it to try and discover why the error message is coming
out twice. After executing the Exit Sub line, it continues processing
from line 12!! If I remove the statement lines 10-12, it goes to line
7. Help. What is happening?
1 Private Sub Form_Current()
2 On Error GoTo Form_Current_Err
3
4 RecCount = Me.Recordset.RecordCount
5 Dim lngRed As Long, lngWhite As Long
6
7 lngRed = RGB(255, 0, 0)
8 lngWhite = RGB(255, 255, 255)
9
10 If IsNull([BalanceDue]) Or [BalanceDue] = 0 Then
11 [BalanceDue] = DateAdd("ww", -8, [DateOfArrival])
12 End If
13
14 If [BalanceDue] < Date And [Balance] <> 0 Then
15 [BalanceDue].BackColor = lngRed
16 Else
17 [BalanceDue].BackColor = lngWhite
18 End If
19
20 If Deposit < (RentalAmount / 3) - 0.01 And FullPayment <>
RentalAmount Then
21 MsgBox "Warning: Deposit " & Deposit & " is less than 1/3rd of
Rental Amount. Deposit should be at least " & Format(RentalAmount / 3
- 0.01, "$###0.00")
22 End If
23
24 Form_Current_Exit:
25 Exit Sub
26 Form_Current_Err:
27 MsgBox Err.Number & ":" & Err.Description
28 End Sub
Stapes- Hide quoted text -

- Show quoted text -

Hi

Thanks for that. It didn't work, How bizarre. You expect these things
to follow a logical sequence - and they don't. My faith is shattered.
Is this a bug in Access 2003? You say that the form-current section
can fire twice. Why is this, and can it be prevented?

Stapes
 

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