ComboBox - Do not show item chosen in the previous record (1 Viewer)

JotaPA

New member
Local time
Today, 21:12
Joined
Mar 11, 2023
Messages
1
Hi!
I want to control the movement of incoming and outgoing tools in a certain warehouse.
In a table, I created the control fields;
txt_Data; txt_Hora; cbo_Tipo; cbo_Motivo; cbo_Responsavel; txt_Obs.

image_10.png


What I want is:

In the first record/row, the value in the 'cbo_Tipo' field should always be 'Entrada'.
In the following records, the value in this field must be different from the value entered in the same field of the previous record.
In other words, after an 'Saída' movement, only an 'Entrada' movement can occur, and vice-versa.
The ideal would be that the 'cbo_Tipo' control only shows for choice options, all the available items except the item chosen in the previous record.
In the example in the image, the user could only have the chance to choose the 'Entrada' option since the previous movement type was 'Saída'.

Thanks for any help.
JotaPA
 

June7

AWF VIP
Local time
Today, 12:12
Joined
Mar 9, 2014
Messages
5,487
Why are these values alternating? Are all 3 records for the same tool?

Combobox has only 2 choices? Why bother with combobox? Why allow user to make choice?

This has the traits of a library check in/out database. Might review MS Access LendingLibrary template.
 
Last edited:

Pat Hartman

Super Moderator
Staff member
Local time
Today, 16:12
Joined
Feb 19, 2002
Messages
43,331
Agreed. How do you determine "first"? How do you determine "subsequent"? Applying whatever rules you define, you can use domain functions to determine a "first" record or a "subsequent" record and fill in the value for the user.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 04:12
Joined
May 7, 2009
Messages
19,247
instead of using combobox, you can "automatically" assign the value for your Tipo field.
see the code on BeforeInsert event on the subform.
 

Attachments

  • EntradaSaida.accdb
    444 KB · Views: 61

CJ_London

Super Moderator
Staff member
Local time
Today, 21:12
Joined
Feb 19, 2013
Messages
16,627
On my phone but what happens if a record is missed? - op would then be forced to enter when they want to exit.
 

The_Doc_Man

Immoderate Moderator
Staff member
Local time
Today, 15:12
Joined
Feb 28, 2001
Messages
27,210
@JotaPA - one difficulty in what you asked has to do with looking at the previous record. Unless your record source has an element that will support a strict and unequivocal ordering of records, there IS no "previous record" in Access. If the form is based on the raw table, there CERTAINLY is no reliable "previous record." Access is not like Excel where the "next/previous" concept is trivially predictable. Access doesn't store data in the same way that Excel does.

In a form where you are entering data, it becomes possible for you to separately determine the most recent state of something (in or out) and do something with that information. In a query, that determination is still possible but much more complex.
 

Users who are viewing this thread

Top Bottom