Display button or not in a row in continuous forms (1 Viewer)

gadjet

Registered User.
Local time
Today, 12:06
Joined
Jan 21, 2008
Messages
45
Hi,
I'm trying to enable/disable a delete button in a row on a continuous form depending on whose logged in.

I've looked at using : -
Private Sub Detail_format(Cancel As Integer, FormatCount As Integer)

But I think this will only work for reports.

Does anyone know how I can runn code as the row is being written "so to speak" so I can enable/disable a button on a row by row basis?

Cheers,
Gadjet
 

RuralGuy

AWF VIP
Local time
Today, 05:06
Joined
Jul 2, 2005
Messages
13,826
Have you tried the Current event of the Form?
 

gadjet

Registered User.
Local time
Today, 12:06
Joined
Jan 21, 2008
Messages
45
Have you tried the Current event of the Form?

Just tried that but no joy!

I think that that would only affect thing on the form that are not repeated.

Thanks for the suggestion, it's given me another idea, I'll let you know if it pans out.


Gadjet
 

gadjet

Registered User.
Local time
Today, 12:06
Joined
Jan 21, 2008
Messages
45
Bit of a compromise but I can get it to work if I put the delete record button in the form header instead of the detail section.

Using the Form_Current method, If I click on a row the button, in the header, is enabled/disabled as required.

That will have to do for now.

Cheers,
Gadjet
 

RuralGuy

AWF VIP
Local time
Today, 05:06
Joined
Jul 2, 2005
Messages
13,826
Just tried that but no joy!

I think that that would only affect thing on the form that are not repeated.

Thanks for the suggestion, it's given me another idea, I'll let you know if it pans out.


Gadjet
What version of Access are you using. I just tested the current event in acXP and I can set a command button visible property false. It is on a continuous form with the button on each record and all of the buttons dissappear. I thought that was what you were looking for.
 

gadjet

Registered User.
Local time
Today, 12:06
Joined
Jan 21, 2008
Messages
45
What version of Access are you using. I just tested the current event in acXP and I can set a command button visible property false. It is on a continuous form with the button on each record and all of the buttons dissappear. I thought that was what you were looking for.

I'm using access 2003.

What I was after is the button to be visible only on the rows with a particular name in the name field.

Basically this will only let the user delete records that were entered by him/her and not allow him/her to delete other users data.
 

RuralGuy

AWF VIP
Local time
Today, 05:06
Joined
Jul 2, 2005
Messages
13,826
Ahh...ok, I simply did not understand the requirement. As you discovered, Command Buttons do not respond to conditional formatting. Your current solution will probably be the best you can expect. Thanks for posting back.
 

missinglinq

AWF VIP
Local time
Today, 07:06
Joined
Jun 20, 2003
Messages
6,423
One work around is using the fact that textboxes do allow Conditional Formatting and do have a Click event, and thus can be used just like a command button.

  1. Place your textbox
  2. Set the controlSource to = "Click Me" where Click Me is the caption you want
  3. Set Special Effect to "Raised"
  4. Goto Properties - Events and set the OnClick event action thru code or a macro or whatever
Now you have a textbox to carry out your action, and you can use Conditional Formatting to enable/disable it

Linq
 

gadjet

Registered User.
Local time
Today, 12:06
Joined
Jan 21, 2008
Messages
45
One work around is using the fact that textboxes do allow Conditional Formatting and do have a Click event, and thus can be used just like a command button.

  1. Place your textbox
  2. Set the controlSource to = "Click Me" where Click Me is the caption you want
  3. Set Special Effect to "Raised"
  4. Goto Properties - Events and set the OnClick event action thru code or a macro or whatever
Now you have a textbox to carry out your action, and you can use Conditional Formatting to enable/disable it

Linq

Thanks Ling, that sounds like a great idea, I'll give that a try tomorrow, I think the cat will get skinned:)
 

gadjet

Registered User.
Local time
Today, 12:06
Joined
Jan 21, 2008
Messages
45
Thanks Linq,
Works like a charm.

Not quite as nice looking as a button but it does the job.

Thanks
Gadjet
 

RuralGuy

AWF VIP
Local time
Today, 05:06
Joined
Jul 2, 2005
Messages
13,826
That was a great idea Linq and another example of your "thinking outside the box". Good on ya mate.
 

dartagnan1098

New member
Local time
Today, 04:06
Joined
Dec 4, 2008
Messages
4
I am trying your suggestion, but I am not having much luck.

Here is what I have so far.

Me.Recordset.MoveFirst
Do Until Me.Recordset.EOF = True
If Me.Text63.Value = "MC" Then
Me.Text62.Enabled = True
Else
Me.Text62.Enabled = False
End If
Me.Recordset.MoveNext
Loop

Text62 is always disabled. I want text62 to be enabled if text63 = MC. This should happen line by line.

Also, I tried putting "Verifications" in Control Source. The text field shows #Name? when the form loads.
 

bhavdahl

Registered User.
Local time
Today, 06:06
Joined
Feb 4, 2008
Messages
17
This is my question as well. Namely...

How do you set enabled to true on a control for a record where a condition, in that record, is met and false where it isn't on a continuous form?

The current event doesn't work. Doesn't seem to be a good event for that in the list on the form.
 

dartagnan1098

New member
Local time
Today, 04:06
Joined
Dec 4, 2008
Messages
4
Just to recap. I did use the suggetion posted by missinglinq. Also, to label the text box I used the following format in the Control Source field. ="IN/ES".

However, I was not able to programmatically enable/disable the text box based on a field or fields in the form. I ended up using Conditional Formatting and it works great.

You will need to select the text box or field you want to enable or disable. Then go to the Format menu and select Conditional Formatting. Once opened you will see an area for Default Formatting and another for Condition 1. Under Condition 1 I used Expression Is from the drop down and then typed in a condition like [text 63].value = "MC". If the condition is True then I enabled the field by clicking the Enabled icon. This is the icon furthest to the right. You can also set the color to make the text box appear enabled. I made the color dark gray, bold and underlined.

Hope that helps. Any questions please let me know.
 

bhavdahl

Registered User.
Local time
Today, 06:06
Joined
Feb 4, 2008
Messages
17
Thanks!! That works great. I didn't really understand what missinglinq meant. I guess cause I wasn't trying to have anything happen when I clicked on something. Since they were talking about buttons vs. a textbox I figured he just meant you could format a text box, so use it instead of a button. ...and didn't know where to find Conditional Formatting. ...etc.

Anyway, thanks again. This'll come in handy!!
 

Users who are viewing this thread

Top Bottom