Page 1 of 2 12 LastLast
Results 1 to 15 of 21
  1. #1
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389

    Coding for know Other form' s boolean confirmation


    I have two forms, first "entry" and second "list". Data entry is done in one form (entry) and record list is shown in the other form (list). When any record is double clicked on the list form, then that record becomes open for editing in the entry form. In the list form, dim db dclick is set as Boolen and in the double click event, coding is done so that as soon as the user double clicks on any record, dclick = true.
    Now the problem comes that when the entry form is opened, in the entry form I have to find out whether the dclick of the list form is true or false. Is there any coding by which I can know that the dclick boolean of the list form has become true.
    Thank you.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    assuming the listbox has ID as the bound field

    Code:
    sub listBox_DoubleClick()
       docmd.SetWarnings false  
    docmd.OpenQuery "qaSet1EditRecTrue
      docmd.openform "fEdit1Rec", , ,"[id]=" & lstBox
     docmd.SetWarnings true
    end sub
    qaSet1EditRecTrue sql would be like: update table set [editFlag]=true where [id]=" & lstBox


    then when done editing the record, and form is closed:

    Code:
    Private Sub Form_Unload(Cancel As Integer)
    
    
    DoCmd.SetWarnings False
      DoCmd.OpenQuery "qaSet1EditRecFalse"
    DoCmd.SetWarnings True
    End Sub
    qaSet1EditRecFalse sql would be like: update table set [editFlag]=false where [id]=" & me.ID

  3. #3
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    4,940
    You seem to like doing everything the hard way?
    What is the significance of opening the form from the list box?, as opposed to just opening the edit form

    I would set a Tempvar and check that, or use OpenArgs in the edit form.
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  4. #4
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,654
    I have to find out whether the dclick of the list form is true or false.
    Why? What is the significance of the boolean value?
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  5. #5
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    Quote Originally Posted by ranman256 View Post
    assuming the listbox has ID as the bound field

    Code:
    sub listBox_DoubleClick()
       docmd.SetWarnings false  
    docmd.OpenQuery "qaSet1EditRecTrue
      docmd.openform "fEdit1Rec", , ,"[id]=" & lstBox
     docmd.SetWarnings true
    end sub
    qaSet1EditRecTrue sql would be like: update table set [editFlag]=true where [id]=" & lstBox


    then when done editing the record, and form is closed:

    Code:
    Private Sub Form_Unload(Cancel As Integer)
    
    
    DoCmd.SetWarnings False
      DoCmd.OpenQuery "qaSet1EditRecFalse"
    DoCmd.SetWarnings True
    End Sub
    qaSet1EditRecFalse sql would be like: update table set [editFlag]=false where [id]=" & me.ID
    It will not work.
    Let me explain again, I have two simple forms in a file, one form has boolen and in the same form it can be made true or false. (Suppose by clicking on any button present on that form).
    Now I have to check the boolen created in the first form in the second form created in the same file whether the user has set true or false by clicking the button in the form containing boolen. How will he be identified?

  6. #6
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    Quote Originally Posted by moke123 View Post
    Why? What is the significance of the boolean value?
    This will take too long to understand, just understand that I have two simple forms in a file, one form has boolen and in the same form it can be made true or false. (Suppose by clicking on any button present on that form).
    Now I have to check the boolen created in the first form in the second form created in the same file whether the user has set true or false by clicking the button in the form containing boolen. How will he be identified?

  7. #7
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    How long can it take to describe the function of a Boolean, it's either Yes or No?
    You are testing something for a yes or no, what are you testing, and why?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  8. #8
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 11 Office 365
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,654
    Quote Originally Posted by deepaksharma View Post
    This will take too long to understand, just understand that I have two simple forms in a file, one form has boolen and in the same form it can be made true or false. (Suppose by clicking on any button present on that form).
    Now I have to check the boolen created in the first form in the second form created in the same file whether the user has set true or false by clicking the button in the form containing boolen. How will he be identified?
    So in other words, we have to guess at what your trying to do?

    My first guess is that your trying to use the same form for data entry and also data edits. Am I right or should I take another guess?
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  9. #9
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    Quote Originally Posted by moke123 View Post
    So in other words, we have to guess at what your trying to do?

    My first guess is that your trying to use the same form for data entry and also data edits. Am I right or should I take another guess?
    I am posting a sample program inside it I have coded in the on load event of the form named "New" that whenever the form is opened a new one is opened with empty record and in before update event coding for the box of new id number in the form A new ID number will show up.
    Apart from this, I have created a form named Register, in which by double clicking on any ID number, it can be opened in the form named "New" for editing.
    Since all the IDs in the form named Register are old and in the new form, coding is done to open a new record in the on load event as soon as the new form is opened, then both these conditions cross each other.
    So I want to bypass the command to open a new record with if condition.
    So what I wanted was to set it to boolean in the register form and set it to true in the double click event and then check it in the onload event of the new form to bypass the new record command if the condition is true.
    Attached Files Attached Files

  10. #10
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Just use an the open Args property on the OpenForm command, and set that accordingly depending where you are opening the form from.

    No need for anything more sophisticated, that's what it is designed for.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  11. #11
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    Quote Originally Posted by Minty View Post
    Just use an the open Args property on the OpenForm command, and set that accordingly depending where you are opening the form from.

    No need for anything more sophisticated, that's what it is designed for.
    You are right but if you look at the coding done in the on load event of the new form of the program I uploaded earlier, the problem is arising due to this.
    Is there any way to bypass the coding?

  12. #12
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Look at the attached.

    It uses the openargs to determine what mode to operate the form in.
    No need for recordsets or other complicated methods.

    I also put the default value in the New Form for the employee number so that it's not dirtying the form unless you save it, so you can probably simplify the other complicated gymnastics in the Before update event.
    Attached Files Attached Files
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  13. #13
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    Quote Originally Posted by Minty View Post
    Look at the attached.

    It uses the openargs to determine what mode to operate the form in.
    No need for recordsets or other complicated methods.

    I also put the default value in the New Form for the employee number so that it's not dirtying the form unless you save it, so you can probably simplify the other complicated gymnastics in the Before update event.
    Thank you minty
    This method seemed fine but there was a problem in it. I opened the register form, double clicked on any ID number and opened it in the form named "new", then made changes in the record and clicked on "Save and Shades" button and then made changes in the sub form also. As soon as the save button was clicked, the empno of the record changed and got converted to the latest empno.

  14. #14
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    Well, that's your code in the form buttomn doing that, not mine.

    You should check to see if there is already a value in the Empno, and not update it in fact you should lock that to prevent edits, and only ever populate it with code.
    Most of the time the default value will do everything you need it to do. I can't see why you would ever want to change it from the initial default value, created on a new record.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  15. #15
    deepaksharma is offline Competent Performer
    Windows 7 32bit Access 2016
    Join Date
    Jul 2023
    Location
    india
    Posts
    389
    Quote Originally Posted by Minty View Post
    Well, that's your code in the form buttomn doing that, not mine.

    You should check to see if there is already a value in the Empno, and not update it in fact you should lock that to prevent edits, and only ever populate it with code.
    Most of the time the default value will do everything you need it to do. I can't see why you would ever want to change it from the initial default value, created on a new record.
    Hello micron, I have made all the changes suggested by you in this program and I have made some changes in its coding so that now this program has become completely suitable for me and the search box created in the "New" form is also working perfectly.
    Now a small problem is arising in this that when the user double clicks on any old record in the "Register" form and opens it for editing in a form named "New" and after editing it, saves it and then continues new data entry in the same open form. What is the reason why a new number is not created in the empno box while continuing new record entry?
    Whereas if new entries are made by directly opening the "New" form then there is no problem as the new number in empno keeps getting auto generated (due to before update event).
    Attached Files Attached Files

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 4
    Last Post: 09-09-2017, 10:24 PM
  2. Data Confirmation Screen on Form
    By chaddresnick in forum Access
    Replies: 4
    Last Post: 03-29-2015, 10:11 AM
  3. Replies: 6
    Last Post: 11-24-2012, 06:50 PM
  4. Confirmation on what I am doing
    By newtoAccess in forum Access
    Replies: 5
    Last Post: 12-10-2010, 01:01 PM
  5. Replies: 3
    Last Post: 11-16-2010, 10:08 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