|
-
Jul 28th, 2000, 01:46 PM
#1
Thread Starter
Hyperactive Member
Okay, here's the situation: I am using ADODC and Access 2000, and I need a certain field to be required only when a boolean value is true. I can't change the attributes of the table on the fly because it is a multi-user program. I have tried things such as
Code:
Private Sub Adodc1_WillChangeRecord(ByVal adReason As ADODB.EventReasonEnum, ByVal cRecords As Long, adStatus As ADODB.EventStatusEnum, ByVal pRecordset As ADODB.Recordset)
If Me.Visible = False Or MyBoolean = False Then Exit Sub
If adReason = adRsnUpdate And dbcGroup = "" Then
MsgBox "Must enter a group."
dbcGroup.SetFocus
adStatus = adStatusCancel
End If
End Sub
and I have tried putting similar code in the other events. All has been to no avail because everything gives me an error somewhere.
Help?
-
Jul 28th, 2000, 03:17 PM
#2
Frenzied Member
Have you tried:
[code]
<font color="#00007F">If</font> adReason = adRsnUpdate then
<font color="#00007F">If</font> len(dbcGroup) < 1 or <font color="#00007F">IsNull</font>(dbcGroup) <font color="#00007F">Then</font>
MsgBox "Must enter a group."
dbcGroup.SetFocus
adStatus = adStatusCancel
<font color="#00007F">End</font> <font color="#00007F">If</font>
<font color="#00007F">End</font> <font color="#00007F">If</font>
[\code]
-
Jul 28th, 2000, 03:21 PM
#3
Frenzied Member
Appears to be a bug if you preview embeded code before posting. Response was supposed to be:
[code]
If adReason = adRsnUpdate then
If len(dbcGroup) < 1 or IsNull(dbcGroup) Then
MsgBox "Must enter a group."
dbcGroup.SetFocus
adStatus = adStatusCancel
End If
End If
[\code]
bug left for amdinistrators.
Originally posted by JHausmann
Have you tried:
[code]
<font color="#00007F">If</font> adReason = adRsnUpdate then
<font color="#00007F">If</font> len(dbcGroup) < 1 or <font color="#00007F">IsNull</font>(dbcGroup) <font color="#00007F">Then</font>
MsgBox "Must enter a group."
dbcGroup.SetFocus
adStatus = adStatusCancel
<font color="#00007F">End</font> <font color="#00007F">If</font>
<font color="#00007F">End</font> <font color="#00007F">If</font>
[\code]
-
Jul 28th, 2000, 05:28 PM
#4
Thread Starter
Hyperactive Member
Okay, that seems to work fairly well, but the only problem is that it cancels the entire transaction and the user has to fill in EVERY FIELD again. Any more tips?
-
Jul 28th, 2000, 06:10 PM
#5
Frenzied Member
If adReason = adRsnUpdate then
If len(dbcGroup) < 1 or IsNull(dbcGroup) Then
MsgBox "Must enter a group."
dbcGroup.SetFocus
End If
End If
put the above in the lost focus event for dbcgroup
-
Jul 28th, 2000, 07:26 PM
#6
Thread Starter
Hyperactive Member
JHaussman thanks for trying to help, but with your last
suggestion the error message shows and then the recordset
moves anyway. I also tried saving the entered data into
some variables, cancelling the transaction, adding a new
record again, and pasting the saved values back into the
recordset. But that makes the program crash 
Thanks again for trying, but I think I will quit this line
of work before it stresses me to death. At least until
9:00 tomorrow morning.
-
Jul 28th, 2000, 07:47 PM
#7
Frenzied Member
Remove these two lines from your if condition that sets focus to the field:
MsgBox "Must enter a group."
adStatus = adStatusCancel
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|