Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    Join Date
    Feb 2007
    Posts
    348

    Unanswered: Access VB learning while working

    I'm working on and Access DB that I am building from scratch. I'm into the coding part and am hitting snag after snag. If anyone knows a good general resource (cause their help isn't helping) I'd appreciate it. Now one to my specific questions:
    This database represents the digitization of something that used to be kept on paper, so I am trying to mimic that approach. So I have a large form (PatientFRM) which has a subform (VisitFRM) which has a subform (Consultation FRM) which has a subform (LabsFRM). The relationships all exist and the data is all cool.
    What I want to do is hide every subform below the one that is currently being worked in. I can hide them easy enough Form_VisitFRM.Visible = False or Forms!VisitFRM = False. The problem comes when I want to back out of it. If I am in VisitFRM and hide the subforms, no problem, it's when I want to hide VisitFRM that I hit a snag. I am assuming this is because I am trying to hide the form from which the command is coming. I tried to set the focus to the next higher form then call it but that didn't work, which I can kinda understand.
    So what I am guessing is I have to build some kind of sub procedure and the PatientFRM (that form will never be hidden) level and somehow call it from the lower form. Is that correct? and how do I call a different form's subprocedure?

    Thanks.

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    @ "general resource" - MSAccess help is suprisingly good! Other than that - feel free to PM/post replies to this thread and we can see what's what!

    As from calling from different subprocedures - they have to have focus to run.
    So I think you have to give it focus, run the command and restore the focus.([Forms]![FormName].SetFocus (?)).
    George
    Home | Blog

  3. #3
    Join Date
    Feb 2007
    Posts
    348
    @ references, it could be an issue of not knowing how to ask help yet. I have found that in other apps, you have to have a certain competency for the help to give you what you need.

    As for giving focus:
    I tried something and it didn't work, I may be way off the mark on what you suggested but I'm gonna run it by you and maybe you can tell me what I missed.
    I'm in VisitFRM. I can hide any of the other three forms with a Forms!SomeFRM.Visible = False where SomeFRM is a form name. I throw an error if I try to use VisitFRM in place of SomeFRM. So what I tried was writing a Sub in Form_PatientFRM that says:
    Code:
    Public Sub CloseVisit()
    Forms!VisitFRM.Visible = False
    End Sub
    and I experimented with Private and Public Subs to no avail
    Then in Form_VisitFRM I added:
    Code:
     Forms!patientfrm.SetFocus
     Form_PatientFRM.CloseVisit
    That bombed out with a 2450 and throws me to the line of
    Code:
    Form_PatientFRM.CloseVisit
    so I assume I am calling it wrong

  4. #4
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Quote Originally Posted by starkmann
    That bombed out with a 2450
    stick this in the code and see what it says - it can often be useful to return the description of the error:
    Code:
    On Error GoTo Something_Err
    
    <yourcode>
    
    Something_Exit:
    Exit Sub
    
    Something_Err:
    'Chr(9) is tab, Chr(13) is carriage return
    MsgBox "Error Number:" & Chr(9) & Err.Number & Chr(13) & "Error Description:" & Chr(9) & Err.Description
    Quote Originally Posted by starkmann
    Code:
    Form_PatientFRM.CloseVisit
    I've never used CloseVisit before, I will go have a play with it now. Perhaps you can upload a small sample of your App with dummy data and only the necessary forms/reports/queries.


    Quote Originally Posted by starkmann
    @references, it could be an issue of not knowing how to ask help yet.
    In the past when I have got stuck I simply searched what I am trying to achieve such as: 'calculating ages in query' and it searchers the online help too - which occasionally has just what you're looking for!
    s'always worth a try
    George
    Home | Blog

  5. #5
    Join Date
    Feb 2007
    Posts
    348
    I'll try to get a copy of the app, I assume I just need to place the .mdb file on the web? Sorry never done it this way. There is only dummy data and it's not very good, it's just jibberish, I literally started from scratch and I'm pretty new to the whole app development concept so it's probably a mess.
    I'll try your code in just a minute to see what happens.

    The CloseVisit thing isn't and built in function, I was trying to write my own.

    It sounds like my searches are being too specific, I tend to search on exactly the command I think I want.
    Last edited by starkmann; 02-22-07 at 11:48. Reason: added output of error test code

  6. #6
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Well if there's no sensitive data in the database then you can simply send it to a zipped folder and upload it in your next post!

    I'm having problems visualising your problem so seeing it should probably help

    Liiiike - what's firing these events to hide and unhide the subforms stuffs?
    George
    Home | Blog

  7. #7
    Join Date
    Feb 2007
    Posts
    348
    oh, no prob, compressing now and it should be attached.

    The event that sets off the code is a command button. The form shows the patient info, then you click Open Visit and it shows the visit info. Then you can enter stuff or click Open Consultation and the same with labs. Then you can back out with Close Labs, Close Consultation, Close Visit buttons.

    Oh I should mention, if you open the file, I don't have the form popping up just yet, I know how to, I just don't like to until I'm almost done with it. So you need to open PatientFRM. This is the form from which everything begins.

    Thanks for your help
    Attached Files Attached Files

  8. #8
    Join Date
    Jun 2004
    Posts
    92
    I think my brain is going numb after a day of working and then wrestling with your db. I think the main issue is the design of the form. Having as many subforms nested in each other as you do, and trying to learn design etc.. at the same time is making it harder on you.

    Instead of having a main form and then subforms inside of one another, you could look at having seperate forms that are linked off of your main form and accessed by your buttons. Either that or have one subform on the main form and change it's source depending on what you want to see.

    Before I looked at your DB I had a solution for you until I realized what you wanted. Maybe it will help you in the future. It can be called from the on_click event of a button, among other places, with "Call HideStuff". It basically causes all forms except the one you are currently on to be hidden. You could reverse it with a frm.visible = true.

    Code:
    Public Function hidestuff()
        Dim frm As Form
        Dim frmactive As Form
        Set frmactive = Screen.ActiveForm
        For Each frm In Forms
            If frm.Name <> frmactive.Name Then
                frm.Visible = False
            End If
        Next
    End Function

  9. #9
    Join Date
    Feb 2007
    Posts
    348
    Some good stuff there. I had started out with seperate forms and in the course of things ended up with this. I'll look at what I can do to head back toward multiple forms. Thanks for the suggestion.
    Your code looks valuable and I'll hang onto but it looks like it still misses one of the issues that I would face with seperate or nested forms. It hides all the forms but the currently active one. The challenge I am facing is hiding the form that is currently active, the one the button resides on. It doesn't seem to be possible so I assume I have to setfocus to another form but I fail whenever I try. I assume this is because the focus has to return to the form on which the sub was begun in order to complete.
    When I was working with the concept of multiple forms, I also had a toolbar, I realized as I drove home that bringing back the toolbar may be the solution.

  10. #10
    Join Date
    Jan 2007
    Location
    California, USA
    Posts
    520
    Starkmann, as I understand it from reading this post, you have form 4 in form 3, and form 3 in form 2, and form 2 in form 1. Therefore subforms with a subform in the subform, etc. Having done this more than once, it is no problem when you finally understand how Access looks at this. I can say "finally" because it took me a lot more than a minute or two. When ever you have a subform, no matter how deep it is in other subforms, it is referenced from the form it is in. So, form 3 is in form 2 (in my example). So, to hide form 3, while in form 3, you first have to move to form 2. (Stick with me, we are getting hairy!) So, form 2 is in form 1, so to set the focus onto form 2, you have to first set the focus on the subform control that holds form 2. The code would look something like:
    Code:
    Forms!form1!subFormControlForm2.SetFocus
    Forms!form1!subFormControlForm2.Form!SomeControlOnForm2.SetFocus
    Forms!form1!subFormControlForm2.Form!subFormControlForm3.Visible = False
    So, we had to step to the control on form2 (2 steps) and then, and only then could we make form 3 hidden by hiding the subform control that holds form 3.
    HTH,

  11. #11
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    I had a quick peek yesterday and I have to agree with sionus!
    that many nested subforms is far too complex for what you want (and think about it from a users perspective too!).

    I suggest you tabulate (yeah, I know I never said I use tabs but here's a prime example of where to use them).

    I suggest you use lisboxes which, when you highlight/select an instance in them, tab 2 becomes enabled and if you navigate to it it will ahve the details like the 2nd form.

    1 form with 4 tabs would be much, much more user friendly (imho)!
    George
    Home | Blog

  12. #12
    Join Date
    Feb 2007
    Posts
    348
    Thanks for all the tips. I bought a book last night, did some reading. Came in early and played with it. In the end, you can't make the item you are in invisible, I tried golferguys solution because changing the focus looks like the right answer but it appears that since I ran the code from a class module, I'm not really leaving the subform. I can see a few solutions, They may have to wait until Monday to get their turn though.
    I can appreciate everyones concerns with the subforms. As I mentioned, I initially set out to do a tabbed approach. I will try to play with that again but the people using this form may be unhappy with that. This form mimics a two page sheet they used where they could view all the info on both pages, they have expressed that they would rather scroll through the sheet they way they know it than learn a new interface.
    Which is worse, perpetuate a bad system or annoy your customer?
    I do appreciate the help and I'll update back when I get a chance to play further.

  13. #13
    Join Date
    Apr 2005
    Posts
    2
    Quote Originally Posted by starkmann
    Thanks for all the tips. I bought a book last night, did some reading. Came in early and played with it. In the end, you can't make the item you are in invisible, I tried golferguys solution because changing the focus looks like the right answer but it appears that since I ran the code from a class module, I'm not really leaving the subform. I can see a few solutions, They may have to wait until Monday to get their turn though.
    I can appreciate everyones concerns with the subforms. As I mentioned, I initially set out to do a tabbed approach. I will try to play with that again but the people using this form may be unhappy with that. This form mimics a two page sheet they used where they could view all the info on both pages, they have expressed that they would rather scroll through the sheet they way they know it than learn a new interface.
    Which is worse, perpetuate a bad system or annoy your customer?
    I do appreciate the help and I'll update back when I get a chance to play further.
    Hey - I have a similar client that needed to be coerced into moving away from paper to a "new" way of doing things. I was interested in your problem because our app is also in the health field. I was able to demonstrate that the way they did it on paper was actually somewhat inefficient. It looked efficient because over time they were good at it. So to answer your question "Which is worse, perpetuate a bad system or annoy your customer?" I'd have to say they are both worse - but it all depends on how much they are paying you...

    Anyway I looked at your form(s) and my first impression was "go to tabs" for the sub-tables, and allow the parent record to be displayed. We added some additional VB code to run/open additional subforms where it was required. Also - consider adding some reports to provide views of the data - this might help them see the light.

  14. #14
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    If their current system is innecficient then it needs a rethink anyway.
    However nice it is to emulate the old system as closely as possible, compromises must be made.
    You can bet that someone will turn round after you've completed your system and complain about the scrolling!
    George
    Home | Blog

  15. #15
    Join Date
    Feb 2007
    Posts
    348
    Good stuff there. Thanks.
    I kinda took the weekend off from thinking about it. Looking at it in the pale fluorescent light of Monday, tabs seem like the right way. I recall being married to scrolling on Friday.
    I'll be in touch.
    Thanks again.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •