Command buttons tied to the form

G

Guest

Hello experts,

I'm designing a simple database for a small billard business and I'm having
some problems with controls on forms. here's a little brief:

* Two tables [Tickets] & [Tables]

[Tickets table fields]
-Ticket#
-TimeIN
-TimeOUT
-AmountPaid
-Status

I've created a form for the tickets and added two COMMAND BUTTONS:
(Start Table)
(Close Table)

By default the two buttons must be disabled

When I select a table from the drop down list the following happens:
1- Enable (start table).

Next, if I click (start table):
1- Stamp the [TimeIN] with Now
2- Enable the (close table) button
3- Change [Status] to Busy
4- Disable itself {You can only start a table once}

Next, I click the (close table happens):
1- Stamp the [TimeOUT] with Now
2- Disable the
drop down {you can't change a table after the sale
was closed}
3- Change [Status] to Closed
4- Run a Query

Now to the problem, Enabling/Disabling worked fine but it's carried to ALL
records!because thesecontrols belong to the forms not the records.

How can I tie the controls to the records?

My coding experience is very basic.

Thank you!
 
R

Rick Brandt

Aminov said:
Hello experts,

I'm designing a simple database for a small billard business and I'm
having some problems with controls on forms. here's a little brief:

* Two tables [Tickets] & [Tables]

[Tickets table fields]
-Ticket#
-TimeIN
-TimeOUT
-AmountPaid
-Status

I've created a form for the tickets and added two COMMAND BUTTONS:
(Start Table)
(Close Table)

By default the two buttons must be disabled

When I select a table from the drop down list the following happens:
1- Enable (start table).

Next, if I click (start table):
1- Stamp the [TimeIN] with Now
2- Enable the (close table) button
3- Change [Status] to Busy
4- Disable itself {You can only start a table once}

Next, I click the (close table happens):
1- Stamp the [TimeOUT] with Now
2- Disable the
drop down {you can't change a table after the
sale was closed}
3- Change [Status] to Closed
4- Run a Query

Now to the problem, Enabling/Disabling worked fine but it's carried
to ALL records!because thesecontrols belong to the forms not the
records.

How can I tie the controls to the records?

My coding experience is very basic.

Thank you!


In the Current event of the form you need code to test the data in the record
and enable/disable the buttons as required. The Current event fires each time
you arrive at a different record.

In your case you need to test the data in the fields on each record to determine
what the Enabled/Disabled state of the buttons should be. It can sometimes
simplity the logic if you initially run lines of code to disable everything.
Then your code only has to decide which controls to Enable.

'Disable both buttons to start
Me![Start Table].Enabled = False
Me![Stop Table].Enabled = False

If Me![Status] = "Busy" Then
Me![Stop Table].Enabled = True
ElseIf IsNull(Me![Ticket#]) = False _
And IsNull(Me![TimeIn]) = False Then
Me![Start Table].Enabled = True
End If

The above might be over-simplified, but you should get the idea. You'll need to
test for all possible conditions of an "un-close" record and Enable the buttons
as appropriate. IsNull() can be used to test for fields that are still not
filled out.
 

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