specific equipment list for different projects

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • lavey
    New Member
    • Jan 2015
    • 17

    #16
    Thanks for that,

    I'm getting a "method or data member not found" error for this:

    Code:
    Me.txtProjectID.DefaultValue = Me.OpenArgs
    Do I have to state these methods somewhere first before hand?

    Comment

    • Seth Schrock
      Recognized Expert Specialist
      • Dec 2010
      • 2965

      #17
      Did you put this in the Equipement List form's OnLoad event?

      Comment

      • lavey
        New Member
        • Jan 2015
        • 17

        #18
        yeah I sure did, not sure why its happening.. Do I need to state the method somewhere before calling it?

        the txtProjectID is being highlighted as the error. I change it to p_ProjectID and then the DefaultValue gets highlighted as the error?

        Comment

        • Seth Schrock
          Recognized Expert Specialist
          • Dec 2010
          • 2965

          #19
          Lets try this.
          Code:
          Dim lngProjectID As Long
          lngProjectID = Me.OpenArgs
          
          Me.txtProjectID.DefaultValue = lngProjectID
          This will help me know which part is failing.

          No you don't have state the method before calling it.

          Comment

          • lavey
            New Member
            • Jan 2015
            • 17

            #20
            highlighted is .txtProjectID under the Private Sub Form_Load() event.

            Comment

            • Seth Schrock
              Recognized Expert Specialist
              • Dec 2010
              • 2965

              #21
              So it sounds like a control name has been mistyped. Make sure that txtProjectID is the name of the control (not the control source) of the textbox in the Equipment List form.

              Comment

              • lavey
                New Member
                • Jan 2015
                • 17

                #22
                Same as before, when I fix this issue .DefaultValue = becomes the next error in this situation? :S

                my full code for this:

                Code:
                Private Sub Command66_Click()
                DoCmd.OpenForm FormName:="NavEquipmentList", _
                               View:=acFormAdd, _
                               WhereCondition:="[p_ProjectID]= " & p_ProjectID, _
                               OpenArgs:=Me!p_ProjectID
                End Sub
                I changed acNormal to acFormAdd just to try make it that when the form loads that the fields are empty and don't include the first record in the table - this didn't work.
                changed it back to acNormal and the current issue still persists
                and then:

                Code:
                Private Sub Form_Load()
                Dim lngProjectID As Long
                lngProjectID = Me.OpenArgs
                 
                Me.txtProjectID.DefaultValue = lngProjectID
                End Sub
                I have a text box hidden and the control name is "txtProject ID"

                Comment

                • jforbes
                  Recognized Expert Top Contributor
                  • Aug 2014
                  • 1107

                  #23
                  You might want to try and trap for Null values. Also you can use a Debug.Print to find out what is going on (you should remove or comment them after your code is working well):
                  Code:
                  Private Sub Form_Load()
                     Dim lngProjectID As Long
                     Debug.Print "NavEquipmentList.OpenArgs: " & Me.OpenArgs
                     lngProjectID = Nz(Me.OpenArgs, 0)
                     If lngProjectID <> 0 Then Me.txtProjectID.DefaultValue = lngProjectID
                  End Sub
                  I would also suggest setting breakpoints and stepping through the code to see what the variables contain and what is actually happening.

                  I don't usually set the Form view to acFormAdd and supply a Where Clause as these really are two different ways of using a Form.

                  Additionally, if you provide a Form with a Where Clause that returns no records on a Form with Additions set to False, your Form can act quite strange. You might not be experiencing this, yet. But it looks like you might be getting close.

                  Comment

                  • Seth Schrock
                    Recognized Expert Specialist
                    • Dec 2010
                    • 2965

                    #24
                    If nulls were the problem, then the error would occur when Me.OpenArgs is assigned to the variable. Instead the error is occuring later when the textbox is being referenced. I'll admit that I'm stumped. This is something that I have done many times and I have never had any trouble with it.

                    Comment

                    • jforbes
                      Recognized Expert Top Contributor
                      • Aug 2014
                      • 1107

                      #25
                      It's possible the Form is open in Design View. When testing this out, you'll want to Save the NavEquipmentLis t Form and Close it. I think if this is not done, there is a way to get a Null Value in there. Just a thought.

                      Comment

                      • lavey
                        New Member
                        • Jan 2015
                        • 17

                        #26
                        Even with your method jforbes its still .DefaultValue = as the error - this is weird.. I can't find a similar situation while searching the net also. I guess I'll continue playing around with it and maybe find something

                        Comment

                        • jforbes
                          Recognized Expert Top Contributor
                          • Aug 2014
                          • 1107

                          #27
                          Then, most likely, Me.txtProjectID is not a valid TextBox control on the Form. Which is what Seth was talking about in Post #21, which gives the error "method or data member not found".

                          Try dropping a brand spanking new TextBox on the Form and see if you can set it's Default Value.

                          Comment

                          Working...