Results 1 to 15 of 15
  1. #1
    xwnoob is offline Advanced Beginner
    Windows Vista Access 2000
    Join Date
    Nov 2011
    Posts
    76

    How do i display a form in dataview/edit word in text when selecting it from listbox?

    I have a form which allows user to add records which is called addcommitmentdetail. It has a textbox on top that says " Add Commitment". However, when i open the form in edit mode ( I have created a separate form that has a listbox that displays data and users are able to open the form based on selection) how do i change the words in my textbox on top of the form to " Edit commitment "?

    Also,
    How do i display the records in datasheet view once select a record from the listbox? This is my code i used in a button to display the form :

    DoCmd.OpenForm "AddCommitmentDetail", , , "CommitmentID=" & Me.ListShowCommit.Column(3)
    DoCmd.Close acForm, "SelectEditCommitment"



    but this is only to open to form with the related information

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    One approach:

    Pass a value to form with OpenArgs argument.
    DoCmd.OpenForm "AddCommitmentDetail", , , "CommitmentID=" & Me.ListShowCommit.Column(3), , , "Edit"

    The in the OnCurrent event of the form set the form caption.
    If Me.OpenArgs = "Edit" Then Me.Caption = "Edit commitment"

    If you want datasheet view, set this in the form's property sheet.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    xwnoob is offline Advanced Beginner
    Windows Vista Access 2000
    Join Date
    Nov 2011
    Posts
    76
    Quote Originally Posted by June7 View Post
    One approach:

    Pass a value to form with OpenArgs argument.
    DoCmd.OpenForm "AddCommitmentDetail", , , "CommitmentID=" & Me.ListShowCommit.Column(3), , , "Edit"

    The in the OnCurrent event of the form set the form caption.
    If Me.OpenArgs = "Edit" Then Me.Caption = "Edit commitment"

    If you want datasheet view, set this in the form's property sheet.
    Hmm i tried the openargs but dont really understand how to use it.

    How about this : Is it possible to show a single record in datasheet viewfrom the add form based on my edit form?

    E.g. My editform has the listbox then once i select a record it opens the specific record and its related record in datasheet view?or in some type of table?

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Not following this. Provide project for analysis. Make copy, remove confidential data, run Compact & Repair, zip if still large.

    What is not clear about the OpenArgs?

    Why would a single record need to be in datasheet view?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    xwnoob is offline Advanced Beginner
    Windows Vista Access 2000
    Join Date
    Nov 2011
    Posts
    76
    Haha I understand now what your saying but i dont want to change the caption of the form, i want to change the words of some textboxes inside the form. I tried your method it worked but its not the caption i wanted to change.

    I have attached the database.

    The reason why i want it in a datasheet(or a table format) is because my user wants it. However, if i can change the textboxes name in the form i dont think there will be a need to show a single record in a table/datasheet view.


    Also, its it possible to do this: If i select a recordin the listbox, the listbox would highlight the record selected in a different colour so that it stands out?

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    The textboxes are unbound? You can modify the ControlSource property of textbox.
    If Me.OpenArgs = "Edit" Then Me.textboxname.ControlSource = "=something"

    If it is a label you really want to change then:
    If Me.OpenArgs = "Edit" Then Me.labelname.Caption = "something"

    The listbox should highlight the selected item when it is clicked on.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  7. #7
    xwnoob is offline Advanced Beginner
    Windows Vista Access 2000
    Join Date
    Nov 2011
    Posts
    76
    Hi it worked for my main form but not for my subform.

    This is my code and whenever i run it access says type mismatch...which part of it is wrong?
    If Me.OpenArgs = "Edit" Then Me.Label49.Caption = "something" And Forms!AddCommitmentDetail.facilitysubform.Form.Lab el16.Caption = "something"

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    So the code is behind main form? Referring the suborm elements is tricky. I always give the subform container control a name different from the form it holds, like: ctrFacility. Then refer to element by reference through the container, like:

    Me.ctrFacility.Form.Label16.Caption

    The intellisense popup hints will not fully work with this.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  9. #9
    xwnoob is offline Advanced Beginner
    Windows Vista Access 2000
    Join Date
    Nov 2011
    Posts
    76
    Quote Originally Posted by June7 View Post
    So the code is behind main form? Referring the suborm elements is tricky. I always give the subform container control a name different from the form it holds, like: ctrFacility. Then refer to element by reference through the container, like:

    Me.ctrFacility.Form.Label16.Caption

    The intellisense popup hints will not fully work with this.
    Yea the code is in the oncurrent event of the mainform.

    Well i changed the name of the subform to frmfacilitysub,and not the source object, but it still gave the error of type mismatch....

    If Me.OpenArgs = "Edit" Then Me.Label49.Caption = "something" And Me.frmfacilitysub.Form.Label16.Caption = "something"

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    I did not say to rename the subform, I said rename the subform container control and refer to the container in the code.

    However, I just realized you said the code is behind main form. In which case the OpenArgs is meaningless. The OpenArgs is for the second form.

    I have your project downloaded. Which forms are involved?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    xwnoob is offline Advanced Beginner
    Windows Vista Access 2000
    Join Date
    Nov 2011
    Posts
    76
    Quote Originally Posted by June7 View Post
    I did not say to rename the subform, I said rename the subform container control and refer to the container in the code.

    However, I just realized you said the code is behind main form. In which case the OpenArgs is meaningless. The OpenArgs is for the second form.

    I have your project downloaded. Which forms are involved?
    Addcommitmentdetail form and selecteditcommitment form.


    Are you refering to the subform when you say openargs is for the second form???

  12. #12
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Okay, let's see if I get what you want. I was thinking only two independent forms involved but there are 3 forms of which 1 is a subform.

    1. SelectEditCommitment opens AddCommitment to edit existing record and passes a value with OpenArgs
    DoCmd.OpenForm "AddCommitmentDetail", , , "CommitmentID=" & Me.ListShowCommit.Column(3), , , "Edit"

    2. Based on OpenArgs value modify labels on AddCommitment form and its subform, code in AddCommitment form. The If Then can't be a one-liner because you are doing more than one action (AND is not correct syntax). I should have seen this earlier.
    If Me.OpenArgs = "Edit" Then
    Me.Label49.Caption = "something"
    Me.frmfacilitysub.Form.Label16.Caption = "something"
    End If

    This code works. I expect you want to display something other than 'something'.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  13. #13
    xwnoob is offline Advanced Beginner
    Windows Vista Access 2000
    Join Date
    Nov 2011
    Posts
    76
    Quote Originally Posted by June7 View Post
    Okay, let's see if I get what you want. I was thinking only two independent forms involved but there are 3 forms of which 1 is a subform.

    1. SelectEditCommitment opens AddCommitment to edit existing record and passes a value with OpenArgs
    DoCmd.OpenForm "AddCommitmentDetail", , , "CommitmentID=" & Me.ListShowCommit.Column(3), , , "Edit"

    2. Based on OpenArgs value modify labels on AddCommitment form and its subform, code in AddCommitment form. The If Then can't be a one-liner because you are doing more than one action (AND is not correct syntax). I should have seen this earlier.
    If Me.OpenArgs = "Edit" Then
    Me.Label49.Caption = "something"
    Me.frmfacilitysub.Form.Label16.Caption = "something"
    End If

    This code works. I expect you want to display something other than 'something'.
    thanks it worked :0

    Earlier you said that listboxes already have highlights. Yes i know that but how do i change the colour of the highlight? Whenever i try to print out a listbox the selected record is black in colour( you can't see the white words in the highlighted row...)

  14. #14
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,926
    Printing listbox? You are printing the form? Why? Why not a report?

    I don't know any way to modify highlight color of standard Access. Never had need to. Probably requires creating a custom listbox. Check this http://windowssecrets.com/forums/sho...rol-(Access-2K)
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  15. #15
    xwnoob is offline Advanced Beginner
    Windows Vista Access 2000
    Join Date
    Nov 2011
    Posts
    76
    Quote Originally Posted by June7 View Post
    Printing listbox? You are printing the form? Why? Why not a report?

    I don't know any way to modify highlight color of standard Access. Never had need to. Probably requires creating a custom listbox. Check this http://windowssecrets.com/forums/showthread.php/12695-Custom-Listbox-control-(Access-2K)
    now that you have mentioned it, there is no need for a form to be printed lol....ill tell the user about it.

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

Similar Threads

  1. Edit rtf memo field in Word
    By dbones202 in forum Access
    Replies: 2
    Last Post: 08-12-2011, 11:16 AM
  2. Replies: 1
    Last Post: 08-04-2011, 04:17 PM
  3. Replies: 3
    Last Post: 02-01-2011, 09:47 AM
  4. Replies: 9
    Last Post: 01-20-2011, 02:22 PM
  5. Edit Buttons for a Rich Text Box on Form
    By trb5016 in forum Forms
    Replies: 2
    Last Post: 10-13-2010, 12:28 PM

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