Limit one selection combox values in a session (1 Viewer)

Alhakeem1977

Registered User.
Local time
Today, 19:09
Joined
Jun 24, 2017
Messages
308
Hi,
How can I limit my selection from a combox values once only in one session in a Data entry form with a return message box of duplicate selection?

Sent from my HUAWEI NXT-L29 using Tapatalk
 

theDBguy

I’m here to help
Staff member
Local time
Today, 09:09
Joined
Oct 29, 2018
Messages
21,468
You seemed to have marked this thread as solved. Is it?
 

Alhakeem1977

Registered User.
Local time
Today, 19:09
Joined
Jun 24, 2017
Messages
308
You seemed to have marked this thread as solved. Is it?
No, it isn't.

I don't know I am using Tapatalk mobile application to post my questions, the SOLVED check box selects automatically.

If you could solve my issue of the combox.

Thanks in advance!

Sent from my HUAWEI NXT-L29 using Tapatalk
 

theDBguy

I’m here to help
Staff member
Local time
Today, 09:09
Joined
Oct 29, 2018
Messages
21,468
No, it isn't.

I don't know I am using Tapatalk mobile application to post my questions, the SOLVED check box selects automatically.

If you could solve my issue of the combox.

Thanks in advance!

Sent from my HUAWEI NXT-L29 using Tapatalk
Well, it's hard to say what the solution would be without seeing the problem. However, a dropdown or combobox control has a Row Source property, which dictates what shows up in the dropdown list. So, if you want to limit the list in the dropdown, you simply need to add a criteria in the Row Source SQL to exclude the ones you don't want listed.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 00:09
Joined
May 7, 2009
Messages
19,237
how do you define a session?
by date? invoice no? how?
 

Alhakeem1977

Registered User.
Local time
Today, 19:09
Joined
Jun 24, 2017
Messages
308
how do you define a session?
by date? invoice no? how?
Hi, arnelfp thanks for your prompt response.

I define the session by a query returns the FID and userID and check box set to YES once the form unploaded then another update query will run to set the the check box to NO.

For sure to all of you experts there is simpler way to handle this data entry form that it has a Listbox showing the user his current entries.

My aim is the user should select only one FID (A) from combox in each session.

Thanks in advance!

Sent from my HUAWEI NXT-L29 using Tapatalk
 
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 00:09
Joined
May 7, 2009
Messages
19,237
still find it hard to imagine. why not disable it after the form is saved. or save its value to some variable after the form is saved. then so validation against the variable if the selection on the combo and the variable are not same.
 

Alhakeem1977

Registered User.
Local time
Today, 19:09
Joined
Jun 24, 2017
Messages
308
still find it hard to imagine. why not disable it after the form is saved. or save its value to some variable after the form is saved. then so validation against the variable if the selection on the combo and the variable are not same.
Let us imagine that I have a data entry form with a combobox which has a three values Red, Blue and Green.

When I select Red and save my record then I can see the Red but when I select it will prompt me with a message box says "this record already selected" then I can select Blue and Green for the next record and cannot select Red in the same session unless I close the form for a new session.

Means one selection in the same session.

Thanks!

Sent from my HUAWEI NXT-L29 using Tapatalk
 
Last edited:

arnelgp

..forever waiting... waiting for jellybean!
Local time
Tomorrow, 00:09
Joined
May 7, 2009
Messages
19,237
replace Combo8 with the name of your combo and understand the logic of the code.
Code:
Dim strCombo As String

Private Sub Form_AfterUpdate()
    With Me.Combo8
        .value = ""
        .SetFocus
    End With
End Sub

Private Sub Combo8_BeforeUpdate(Cancel As Integer)
    Cancel = InStr(1, strCombo & "", "/" & Me.Combo8) <> 0
    If Cancel Then
        MsgBox "this item has already been selected"
        
    End If
        
End Sub

Private Sub Form_BeforeUpdate(Cancel As Integer)
    If Trim(Me.Combo8.value & "") <> "" Then
        strCombo = strCombo & "/" & Me.Combo8.value
    End If
End Sub
 

Alhakeem1977

Registered User.
Local time
Today, 19:09
Joined
Jun 24, 2017
Messages
308
replace Combo8 with the name of your combo and understand the logic of the code.
Code:
Dim strCombo As String

Private Sub Form_AfterUpdate()
    With Me.Combo8
        .value = ""
        .SetFocus
    End With
End Sub

Private Sub Combo8_BeforeUpdate(Cancel As Integer)
    Cancel = InStr(1, strCombo & "", "/" & Me.Combo8) <> 0
    If Cancel Then
        MsgBox "this item has already been selected"
        
    End If
        
End Sub

Private Sub Form_BeforeUpdate(Cancel As Integer)
    If Trim(Me.Combo8.value & "") <> "" Then
        strCombo = strCombo & "/" & Me.Combo8.value
    End If
End Sub
Thank you so much it's working fine.

Sent from my HUAWEI NXT-L29 using Tapatalk
 

Users who are viewing this thread

Top Bottom