Record Locking

G

Guest

I have a form with a drop down list.
If a user selects from the drop down list Account Closed, is it possible
then to display a msg box saying "Are you sure you wish to Close Account?
Closed Accounts cannot be re-activated." and then greying out all fields in
records and disallowing edits.

Cheers
 
G

Guest

Not that difficult, but will take some coding in a couple of places.
First, you will need a field in your account record that will show whether
the account is open or closed. I would suggest a Yes/No field with a name
like
[ACCOUNT_OPEN] with a default value of Yes. You will also need a text box
on your form bound to [ACCOUNT_OPEN]. For this example, we will call it
txtAcctOpen

Now, in the After Update event of your combo box:
Dim ctl As Control
If .cboStatus = "Account Closed" Then
If MsgBox("Are you sure you wish to Close Account?",vbYesNo) = vbYes
Then
Me.txtAcctOpen = False
For Each ctl in Me
If ctl.Type = acTextBox or ctl.Type = acComboBox Then
ctl.Locked = True
End If
End If
End IF

You will also need code in the Current event of your form to either Lock or
UnLock the controls depending on whether the account is open or closed.
 
G

Guest

ok, i have done the code:

Private Sub Account_Status_AfterUpdate()
Dim ctl As Control
If .cboStatus = "1 Closed" Then
If MsgBox("Are you sure you wish to close this account? Closed
Accounts cannot be re-activated", vbYesNo) = vbYes Then
Me.txtAcctOpen = False
For Each ctl In Me
If ctl.Type = acTextBox Or ctl.Type = acComboBox Then
ctl.Locked = True
End If
End If
End If

but i keep getting error message invalid or unqualified reference
highlighted over "cboStatus" on the 3rd line.

Why is this.

Klatuu said:
Not that difficult, but will take some coding in a couple of places.
First, you will need a field in your account record that will show whether
the account is open or closed. I would suggest a Yes/No field with a name
like
[ACCOUNT_OPEN] with a default value of Yes. You will also need a text box
on your form bound to [ACCOUNT_OPEN]. For this example, we will call it
txtAcctOpen

Now, in the After Update event of your combo box:
Dim ctl As Control
If .cboStatus = "Account Closed" Then
If MsgBox("Are you sure you wish to Close Account?",vbYesNo) = vbYes
Then
Me.txtAcctOpen = False
For Each ctl in Me
If ctl.Type = acTextBox or ctl.Type = acComboBox Then
ctl.Locked = True
End If
End If
End IF

You will also need code in the Current event of your form to either Lock or
UnLock the controls depending on whether the account is open or closed.

Stevene James said:
I have a form with a drop down list.
If a user selects from the drop down list Account Closed, is it possible
then to display a msg box saying "Are you sure you wish to Close Account?
Closed Accounts cannot be re-activated." and then greying out all fields in
records and disallowing edits.

Cheers
 
G

Guest

Sorry, it should say Me.cboStatus
cboStatus should be the name of your drop down control.

Stevene James said:
ok, i have done the code:

Private Sub Account_Status_AfterUpdate()
Dim ctl As Control
If .cboStatus = "1 Closed" Then
If MsgBox("Are you sure you wish to close this account? Closed
Accounts cannot be re-activated", vbYesNo) = vbYes Then
Me.txtAcctOpen = False
For Each ctl In Me
If ctl.Type = acTextBox Or ctl.Type = acComboBox Then
ctl.Locked = True
End If
End If
End If

but i keep getting error message invalid or unqualified reference
highlighted over "cboStatus" on the 3rd line.

Why is this.

Klatuu said:
Not that difficult, but will take some coding in a couple of places.
First, you will need a field in your account record that will show whether
the account is open or closed. I would suggest a Yes/No field with a name
like
[ACCOUNT_OPEN] with a default value of Yes. You will also need a text box
on your form bound to [ACCOUNT_OPEN]. For this example, we will call it
txtAcctOpen

Now, in the After Update event of your combo box:
Dim ctl As Control
If .cboStatus = "Account Closed" Then
If MsgBox("Are you sure you wish to Close Account?",vbYesNo) = vbYes
Then
Me.txtAcctOpen = False
For Each ctl in Me
If ctl.Type = acTextBox or ctl.Type = acComboBox Then
ctl.Locked = True
End If
End If
End IF

You will also need code in the Current event of your form to either Lock or
UnLock the controls depending on whether the account is open or closed.

Stevene James said:
I have a form with a drop down list.
If a user selects from the drop down list Account Closed, is it possible
then to display a msg box saying "Are you sure you wish to Close Account?
Closed Accounts cannot be re-activated." and then greying out all fields in
records and disallowing edits.

Cheers
 
G

Guest

hmmm. odd its still happeing how do i check the name of the combo box
control, the name of my combo box is "Account Status"

Klatuu said:
Sorry, it should say Me.cboStatus
cboStatus should be the name of your drop down control.

Stevene James said:
ok, i have done the code:

Private Sub Account_Status_AfterUpdate()
Dim ctl As Control
If .cboStatus = "1 Closed" Then
If MsgBox("Are you sure you wish to close this account? Closed
Accounts cannot be re-activated", vbYesNo) = vbYes Then
Me.txtAcctOpen = False
For Each ctl In Me
If ctl.Type = acTextBox Or ctl.Type = acComboBox Then
ctl.Locked = True
End If
End If
End If

but i keep getting error message invalid or unqualified reference
highlighted over "cboStatus" on the 3rd line.

Why is this.

Klatuu said:
Not that difficult, but will take some coding in a couple of places.
First, you will need a field in your account record that will show whether
the account is open or closed. I would suggest a Yes/No field with a name
like
[ACCOUNT_OPEN] with a default value of Yes. You will also need a text box
on your form bound to [ACCOUNT_OPEN]. For this example, we will call it
txtAcctOpen

Now, in the After Update event of your combo box:
Dim ctl As Control
If .cboStatus = "Account Closed" Then
If MsgBox("Are you sure you wish to Close Account?",vbYesNo) = vbYes
Then
Me.txtAcctOpen = False
For Each ctl in Me
If ctl.Type = acTextBox or ctl.Type = acComboBox Then
ctl.Locked = True
End If
End If
End IF

You will also need code in the Current event of your form to either Lock or
UnLock the controls depending on whether the account is open or closed.

:

I have a form with a drop down list.
If a user selects from the drop down list Account Closed, is it possible
then to display a msg box saying "Are you sure you wish to Close Account?
Closed Accounts cannot be re-activated." and then greying out all fields in
records and disallowing edits.

Cheers
 
G

Guest

The name of evey control is in the properties dialog box under Name. That is
how you address it. You should not have a space in the name. If it is
Account_Status, then the code would be Me.Account_Status

Stevene James said:
hmmm. odd its still happeing how do i check the name of the combo box
control, the name of my combo box is "Account Status"

Klatuu said:
Sorry, it should say Me.cboStatus
cboStatus should be the name of your drop down control.

Stevene James said:
ok, i have done the code:

Private Sub Account_Status_AfterUpdate()
Dim ctl As Control
If .cboStatus = "1 Closed" Then
If MsgBox("Are you sure you wish to close this account? Closed
Accounts cannot be re-activated", vbYesNo) = vbYes Then
Me.txtAcctOpen = False
For Each ctl In Me
If ctl.Type = acTextBox Or ctl.Type = acComboBox Then
ctl.Locked = True
End If
End If
End If

but i keep getting error message invalid or unqualified reference
highlighted over "cboStatus" on the 3rd line.

Why is this.

:

Not that difficult, but will take some coding in a couple of places.
First, you will need a field in your account record that will show whether
the account is open or closed. I would suggest a Yes/No field with a name
like
[ACCOUNT_OPEN] with a default value of Yes. You will also need a text box
on your form bound to [ACCOUNT_OPEN]. For this example, we will call it
txtAcctOpen

Now, in the After Update event of your combo box:
Dim ctl As Control
If .cboStatus = "Account Closed" Then
If MsgBox("Are you sure you wish to Close Account?",vbYesNo) = vbYes
Then
Me.txtAcctOpen = False
For Each ctl in Me
If ctl.Type = acTextBox or ctl.Type = acComboBox Then
ctl.Locked = True
End If
End If
End IF

You will also need code in the Current event of your form to either Lock or
UnLock the controls depending on whether the account is open or closed.

:

I have a form with a drop down list.
If a user selects from the drop down list Account Closed, is it possible
then to display a msg box saying "Are you sure you wish to Close Account?
Closed Accounts cannot be re-activated." and then greying out all fields in
records and disallowing edits.

Cheers
 

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