Hey good morning guys from Iraq. I doing a database for my soldiers and I
have a problem so far. I'm try to do a desicion. I want to check the rank
after select the soldier. to give me access to differents command buttons.
Like if the soldier is E-4 and below I don't need access to E-5 command
button. The code that I have is this one and when I executed unable access
to all the command group no matter therir rank.
Dim rs As Object
Set rs = Me.Recordset.Clone
rs.FindFirst "[SS] = '" & Me![Combo1] & "'"
SMName.Visible = True
if (rank="e1") or (rank="e2") or (rank="e3") or (rank="e4") then
NCOER.Enabled = false
Weapons.Enabled = True
OpenSchForm.Enabled = True
PromoForm.Enabled = false
VehForm.Enabled = True
end if
If Not rs.EOF Then Me.Bookmark = rs.Bookmark
If somebody can help I'll be appreciate.
Chaim - 25 Jul 2005 18:15 GMT
Where does 'rank' come from? If it is coming from the recordset clone 'rs'
then you need to reference it like: rs.Fields("rank").value (or just
rs.Fields("rank")).
It also seems like you are mixing DAO and ADO object methods. Clone is an
ADO method; FindFirst is DAO.
You should also test the result of the FindFirst call, in case it comes back
empty. For example, you might want:
set rs = me.recordset.clone
rs.movefirst ' position at start of recordset
rs.find "[SS] = '" & Me![Combo1] & "'"
if rs.EOF = false then ' something was found because we're still in
recordset
<do the rest of your code>
end if
Good Luck!

Signature
Chaim
> Hey good morning guys from Iraq. I doing a database for my soldiers and I
> have a problem so far. I'm try to do a desicion. I want to check the rank
[quoted text clipped - 19 lines]
>
> If somebody can help I'll be appreciate.
Marcelino - 25 Jul 2005 18:32 GMT
The field rank come from the same form that is not visible.
>Where does 'rank' come from? If it is coming from the recordset clone 'rs'
>then you need to reference it like: rs.Fields("rank").value (or just
[quoted text clipped - 20 lines]
>>
>> If somebody can help I'll be appreciate.
Marshall Barton - 25 Jul 2005 18:39 GMT
>Hey good morning guys from Iraq. I doing a database for my soldiers and I
>have a problem so far. I'm try to do a desicion. I want to check the rank
[quoted text clipped - 17 lines]
>
> If Not rs.EOF Then Me.Bookmark = rs.Bookmark
You need to set the control's Enabled property one way or
the other, not just the case when the If is true.
Try something more like this:
Dim rs As DAO.Recordset
Dim bolE4 As Boolean
Set rs = Me.RecordsetClone
rs.FindFirst "[SS] = '" & Me![Combo1] & "'"
If Not rs.NoMatch Then Me.Bookmark = rs.Bookmark
SMName.Visible = True
Set rs = Nothing
'---------------------------
bolE5 = (rank="e1") or (rank="e2") or (rank="e3") or
(rank="e4")
NCOER.Enabled = Not bolE4
Weapons.Enabled = bolE4
OpenSchForm.Enabled = bolE4
PromoForm.Enabled = Not bolE4
VehForm.Enabled = bolE4
You would probably be better off placing the code after the
line '-------- in the form's Current event so it can be used
to syncronize the controls when just navigate from one
record to another without using the combo box.

Signature
Marsh
MVP [MS Access]
Marcelino - 25 Jul 2005 22:49 GMT
It's working 50% because if I have an e5 or above then I don't have the NCOER
and Promo command button available this filter only is apllying to the e4 and
belows. Thanks for your help.
>>Hey good morning guys from Iraq. I doing a database for my soldiers and I
>>have a problem so far. I'm try to do a desicion. I want to check the rank
[quoted text clipped - 28 lines]
>to syncronize the controls when just navigate from one
>record to another without using the combo box.
Marshall Barton - 25 Jul 2005 23:44 GMT
That's why I got rid of the If and used a boolean variable
instead.
Oops, I just noticed a typo, it should be:
bolE4 = (rank="e1") or (rank="e2") or (rank="e3") or
(rank="e4")
all on one line , of course.

Signature
Marsh
MVP [MS Access]
>It's working 50% because if I have an e5 or above then I don't have the NCOER
>and Promo command button available this filter only is apllying to the e4 and
[quoted text clipped - 32 lines]
>>to syncronize the controls when just navigate from one
>>record to another without using the combo box.