Results 1 to 5 of 5
  1. #1
    Shamli is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Jul 2018
    Location
    California
    Posts
    142

    combo box values in the Continuous form

    Hello Everyone,
    I have a bound combo box (CmboTimeclass) in a continuous form.
    It has two values
    1. regular time 2. Overtime
    when the user selects over time, I wanted to check if he had already chosen regular time in the continuous form.
    I tried doing this when he attempts to close the form.


    Since the continuous form hold the value from the current row.
    I am not able to check the previous selections.
    can anyone to tell me how to proceed with this.

    Thanks.

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    you would need a to run a check in the AFTERUPDATE event of the combo.

    Code:
    subCboBox_Afterupdate()
    vVal = Dlookup("[RegTime]","qsHasRegTime1Week1Person")
    if IsNull(vVal) then
       msgbox "No Reg time"
    else
       msgbox "Has Reg Time"
    endif
    end sub


    the query:
    qsHasRegTime1Week1Person
    would query on the form PersonID, and WeekID to see if that person has RegTime.


  3. #3
    Shamli is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Jul 2018
    Location
    California
    Posts
    142
    Thank you for replying.
    I am sorry. I didn't understand your answer.
    I wanted to check only when a user selects a over time.
    When a user selects a over time, I have to check if "Regular Time" is already selected in previous selections.


    Quote Originally Posted by ranman256 View Post
    you would need a to run a check in the AFTERUPDATE event of the combo.

    Code:
    subCboBox_Afterupdate()
    vVal = Dlookup("[RegTime]","qsHasRegTime1Week1Person")
    if IsNull(vVal) then
       msgbox "No Reg time"
    else
       msgbox "Has Reg Time"
    endif
    end sub


    the query:
    qsHasRegTime1Week1Person
    would query on the form PersonID, and WeekID to see if that person has RegTime.

  4. #4
    Shamli is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Jul 2018
    Location
    California
    Posts
    142
    I tried this below code.
    I am not sure if my logic is right.
    Still No luck. I am getting a error in the Findfirst.
    I am trying to check if the user selects Over Time , I am checking if a regular time is selected or not.


    Code:
    Dim db As Database
    Dim rs As Recordset
    Set db = CurrentDb()
    Set rs = db.OpenRecordset("Temp_Timesheet_T")
    Do While Not rs.EOF
    If rs("TimclassID") = 2 Then  '2 is CmboTimeclass ID for Over Time
    rs.FindFirst("TimeclassID") = 1 '1 is cmboTimeclass ID for Regular Time
    End If
    rs.MoveNext
    Loop
     
    If Not rs.NoMatch Then
    MsgBox ("Select a separate record for Overtime")
    End If
     
    rs.Close

    Quote Originally Posted by Shamli View Post
    Thank you for replying.
    I am sorry. I didn't understand your answer.
    I wanted to check only when a user selects a over time.
    When a user selects a over time, I have to check if "Regular Time" is already selected in previous selections.

  5. #5
    Micron is online now Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,803
    1) always post the error message (or a condensed form of it). The error number is useful too. It helps focus the response.
    2) always post the beginning of the procedure so we can know if it's a button click, after update, before update, current, etc. event
    I think you're over complicating this, but you don't say what's supposed to happen if a value is found. This might require your code to be in the BeforeUpdate event of the combo, because if the records isn't supposed to be created, it's too late.

    Also, I'm thinking the set of records (domain) you want to check is on the continuous form. If so, this would probably suffice

    With Me.Recordset
    .FindFirst ("TimClassID = 2")
    If .NoMatch Msgbox "your message here"
    End With

    Again, your info is a bit sketchy for me. If doing this in an event that takes place before the record is saved it might cause unexpected results. You can't include new selections in the check of the record you're on if it hasn't been saved yet. Don't forget - using bound combo boxes on records means that any altered selection will write that selection to the current record, so it's easy to unintentionally change existing data.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Continuous Form/Combo Box
    By Beanie_d83 in forum Forms
    Replies: 9
    Last Post: 06-11-2018, 09:49 AM
  2. Continuous form Combo box control
    By dinsey90 in forum Forms
    Replies: 4
    Last Post: 02-07-2018, 02:48 PM
  3. Combo box on continuous form
    By msmithtlh in forum Forms
    Replies: 12
    Last Post: 11-13-2017, 04:52 PM
  4. Filter a continuous form using a combo box
    By Chky071 in forum Access
    Replies: 5
    Last Post: 05-04-2015, 08:06 AM
  5. Replies: 1
    Last Post: 11-24-2011, 07:45 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums