Results 1 to 7 of 7
  1. #1
    dbdvl is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    8

    Cannot seem to get the value from text box in another form..

    Hello I am trying to access a text field placed in another form. but i could not use it. All i wanted to was.. if the date entered in the form is less than today's date, the user needs to alter it.. else the management should come and override it by granting it permission to put a older date.. the following is the condition..

    Private Sub START_DATE_BeforeUpdate(Cancel As Integer)


    If [START DATE].Value <= Date - 7 Then
    msg = "Please contact Management. Press OK to override, Cancel to edit date"
    Val = MsgBox(msg, vbOKCancel)
    If Val = 1 Then
    typ = PasswordInputBox("Enter the password to proceed")
    If typ = "grant" Then
    MsgBox ("SUCESS")
    Else
    MsgBox ("VERIFICATION Failed !")
    [START DATE].DefaultValue = Date
    End If
    Else
    [START DATE].DefaultValue = Date
    End If
    End If
    End Sub

    I also want the default valure of this start date field to be todays date.. which does not seem to be working either..

    I also want the default valure of this start date field to be todays date..
    The PasswordInputBox is a user defined function as I needed a password field input box.. the following is the code for it..

    Function PasswordInputBox( _
    Prompt As String, _
    Optional TITLE As String = vbNullString, _
    Optional Default As String = vbNullString _
    ) As String

    Dim strOpenArgs As String

    strOpenArgs = "Prompt=" & Prompt
    If Len(TITLE) > 0 Then
    strOpenArgs = strOpenArgs & "~Title=" & TITLE
    End If
    If Len(Default) > 0 Then
    strOpenArgs = strOpenArgs & "~Default=" & Default
    End If

    DoCmd.OpenForm FormName:="frmInputBox_Password", _
    View:=acNormal, _
    WindowMode:=acDialog
    If CurrentProject.AllForms("frmInputBox_Password").Is Loaded Then
    PasswordInputBox = Forms![frmInputBox_Password]!Text3
    DoCmd.Close acForm, "frmInputBox_Password"
    Else
    PasswordInputBox = vbNullString
    End If

    End Function

    the highlighted line is where i want to return whatever is entered into the field.. the following line also does not seem to work.. once OK is pressed it needs to close which is not happening.. please someone help me..

    I can provide the coding for the other form if it is necessary..

  2. #2
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481

    Although I don't know if it is necessary, I always

    put brackets around the pieces of the object until the value/property is referenced.
    PasswordInputBox = Forms![frmInputBox_Password]![Text3].value

    HTH

  3. #3
    dbdvl is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    8
    Hi HTH Thanks for that.. but i believe the problem still persists.. the form that i loaded does not seem to close after i type in the password.. does that have anything to do with the not returning value??

  4. #4
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481

    Your reply suggests that the line in question is not being executed.

    In other words, the 'if' is giving a false and you are skipping the close. I'm not on my Access computer, so I can't step through the code. Suggest you use debug or msgboxes to see what is happening here.

  5. #5
    dbdvl is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    8

    yes.. the if is not executed

    As you said...
    Quote Originally Posted by hertfordkc View Post
    In other words, the 'if' is giving a false and you are skipping the close. I'm not on my Access computer, so I can't step through the code. Suggest you use debug or msgboxes to see what is happening here.
    The if condition seem not to work.. i used a msg box immediately after the if.. it did not come up.. but when i changed the format of the DoCmd.OpenForm"FormName" as such taking away all options.. the form opens and the message box appears.. since the form has been loaded in a normal mode it could not/it did not catch the value entered into the text field.. rather it exits on loading.. any suggestions?

  6. #6
    hertfordkc is offline 18 year novice
    Windows XP Access 2007
    Join Date
    Mar 2011
    Posts
    481

    I'm guessing at what you've learned.

    What happens if you take the
    DoCmd.Close acForm, "frmInputBox_Password"
    out of the function and place it after the function call?

  7. #7
    dbdvl is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Dec 2011
    Posts
    8
    nope... the same.. it is frozen.. if i use the acDialog... if not(i.e without the acDialog) it closes on opening.. no matter where i put the DoCmd.close...

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

Similar Threads

  1. To open a form, sub form if text box entry exist in Query
    By george.vniekerk in forum Programming
    Replies: 2
    Last Post: 08-08-2011, 12:50 AM
  2. Replies: 1
    Last Post: 07-18-2011, 03:08 AM
  3. Replies: 1
    Last Post: 11-07-2010, 11:04 AM
  4. Replies: 15
    Last Post: 09-18-2010, 01:19 PM
  5. Write text to text box on a form
    By DKY in forum Programming
    Replies: 0
    Last Post: 10-08-2008, 11:34 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