inputing data

dkbrostyle

New Member
Joined
Mar 16, 2002
Messages
28
Hi i would like to design a form which enables data to be keyed in. But what i would like to do is that a list of numbers would be keyed in, which would be my primary key numbers and as these numbers are being typed in it is automatically altering the colour of the record. I would like to the form to continuously enable the user to type in the selection of numbers whilst making a selection.

Thank you all for your time and help.
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
Why do you want to enter numeric primary keys? This is likely to cause issues with record creation -- primary keys must be unique and your users will get error messages if they try to use the same value twice.
There's nothing to stop you changing the form background based on the value of a numeric field, or changing the background colour of the particular control contining the value.
Some more clues as to what you need to do?

Denis
 
Upvote 0
I would like to create primary keys, because these numbers are unique it's a project set by school which involves hotel door numbers these numbers are therefore unique and should not be repeated more than once on the table. I would like to create an input-box which do any action such as highlighting, usually my end-user would need to highlight some room numbers on a sheet of paper but now, i'm making it computerised i would need a macro which would allow me to enter a list of numbers which would then highlight those records
 
Upvote 0
OK -- for making the primary key do this.
Create the table in Design view.
Create your key field (Room_No). Make it a Number.
Right-click the grey border on the left, and select the key icon. That makes it the Primary Key.
Now create the other fields as required. Save the table.
You will find that people can only enter each room number once.

That should get you started -- why do you want the colour coding, and how many colours are required? Also, which version of Access do you use?

Denis
 
Upvote 0
I use Microsoft Access XP version. It's important for the colour coding because as previously stated in my project my end-user would like colour coding. Since two departments have the same information some of the room numbers have room service so would need to be highlighted just in case they come for breakfast then the other department would be notified, and the order would be cancelled. My end-user would need to contact the department to do so, so if a list of records are highlighted it would be very helpful.
 
Upvote 0
I think that part of the problem here is that we can't visualize what you are actualy looking for as an end product.

will these room numbers be showing on a form or a report?
will they all be showing at the same time or just as their number is endtered in to a form?
How many room numbers are there?
How many differnt colours could each number need?

Peter
 
Upvote 0
The room number would shown on a form.
The room numbers may vary depending on the number of guest that have made an order through the room service department. For an example it could be 20 numbers one day and the next could be 30.
I would only need one colour which would be preferable red.
 
Upvote 0
Assuming that you have a table called tblService which has a field called RoomID which you input the room number.

On a for create a set of labels, one for each room in the hotel, and label them with the room numbers. For the Label Name use labRoom + the room number ie. labRoom18 for room 18.

The following code added to a button will colour the background of the labels green if the number is not in the table and red if it is.

This I think will do what you need however it does not add much functionality! It would be better to pull the data from an existing table and have it date related so that you do not have to input the service requirements each morning. Presumably, you have some sort of bookings table that lists if service is required.

You could also add more features by adding a click event to the label that would bring up the booking details for the room. You could add a third colour that would show if a room was unoccupied, or add automatic emailing to cancel the order when someone arrives for breakfast when room service is booked.
Code:
Private Sub btnUpdate_Click()
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim strSql As String
Dim j As Integer

For j = 1 To 25
   Me("labRoom" & j).BackColor = vbGreen
Next j

Set dbs = CurrentDb()
strSql = "SELECT [tblService].RoomID FROM [tblService];"
Set rst = dbs.OpenRecordset(strSql)
If rst.EOF = True And rst.BOF = True Then ' no records found
Else
   rst.MoveFirst
   Do While Not rst.EOF
      Me("labRoom" & rst("roomid")).BackColor = vbRed
      rst.MoveNext
   Loop
End If
End Sub

For this code to work in XP you may need to set a reference, in any module go Tools>References... and in the dialog box scroll down to find "Microsoft DAO 3.5 Object Library" and select it. ( the version number may vary!)

HTH

Peter
 
Upvote 0

Forum statistics

Threads
1,221,657
Messages
6,161,084
Members
451,684
Latest member
smllchng5

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top