Results 1 to 5 of 5
  1. #1
    Join Date
    Dec 2003
    Location
    Belfast, UK
    Posts
    87

    Unanswered: Change textbox controlsource

    Hi,

    at the moment I have an unbound textbox that contain the caseid id (only after the user clicks save).
    I'm also using the form to edit records later what I want to do is to assign the caseid as the controlsource but only if the form is being editted.

  2. #2
    Join Date
    Dec 2003
    Location
    Toronto, Ont. Canada
    Posts
    238

    Re: Change textbox controlsource

    Originally posted by bertthefreak
    Hi,

    at the moment I have an unbound textbox that contain the caseid id (only after the user clicks save).
    I'm also using the form to edit records later what I want to do is to assign the caseid as the controlsource but only if the form is being editted.
    I don't understand what you mean by "only if the form is being editted"... Is the form opened in Edit mode?... or does the user have to explicitly say they want to edit (either by custom menu option or button or other control)??

    You'll need something to identify whether the form is being editted or not...

    Say you had a boolean variable called "blnEditMode" that is set to True as the user begins to edit the form...

    You'd need something like...

    If blnEditMode = True Then
    txtYourName.ControlSource = [CaseID]
    Else
    txtYourName.ControlSource = ""
    End If

    I wish I could help more, but without knowing how or when it gets editted, I can't...

  3. #3
    Join Date
    Dec 2003
    Location
    Belfast, UK
    Posts
    87
    the user will select a case to edit from a search form.
    I'm using the following codes.

    searchform
    caseid = me.txtcaseid

    stLinkCriteria = "[IntCase]=" & Me![txtCaseID]
    DoCmd.Close
    DoCmd.OpenForm "frmcase", , , stLinkCriteria, , , caseid

    main form
    Private Sub Form_Open(Cancel As Integer)
    If Not IsNull(Me.OpenArgs) Then
    Me.IntCase.ControlSource = [tables]![tblcase].[IntCase]
    Me.IntCase.Requery
    End If
    End Sub

    it keeps saying object required.

  4. #4
    Join Date
    Dec 2003
    Location
    Toronto, Ont. Canada
    Posts
    238
    Originally posted by bertthefreak
    the user will select a case to edit from a search form.
    I'm using the following codes.

    searchform
    caseid = me.txtcaseid

    stLinkCriteria = "[IntCase]=" & Me![txtCaseID]
    DoCmd.Close
    DoCmd.OpenForm "frmcase", , , stLinkCriteria, , , caseid

    main form
    Private Sub Form_Open(Cancel As Integer)
    If Not IsNull(Me.OpenArgs) Then
    Me.IntCase.ControlSource = [tables]![tblcase].[IntCase]
    Me.IntCase.Requery
    End If
    End Sub

    it keeps saying object required.
    Ugg.... I'm totally confused... lol...

    Okay... You've got a search form... This is going to apply a filter to the edit form as it's opened... You're only going to get one record when it opens correct?

    You want the value in the text box for caseid on the edit form to show the value from the Search form...

    There are a few ways to do this...

    The simplest (and I can't see why you wouldn't be able to do it here) is to set the controlsource in design mode... Your stLinkCriteria assignment statement shows me that [IntCase] is part of your edit form's recordsource... so since a filter's going to be applied on open, why not just set it once and for all?

    Otherwise... Try this...

    Code:
    searchform
        
        stLinkCriteria = "[IntCase]=" & Me![txtCaseID]
        DoCmd.Close
        DoCmd.OpenForm "frmcase", , , stLinkCriteria, , , Me![txtCaseID]
    
    main form
    
    Private Sub Form_Open(Cancel As Integer)
    If Not IsNull(Me.OpenArgs) Then
    Me!IntCase = Me.OpenArgs
    End If
    End Sub
    Or
    Code:
    searchform
        
        stLinkCriteria = "[IntCase]=" & Me![txtCaseID]
        DoCmd.Close
        DoCmd.OpenForm "frmcase", , , stLinkCriteria, , , "Whatever"
    
    main form
    
    Private Sub Form_Open(Cancel As Integer)
    If Not IsNull(Me.OpenArgs) Then
    Me.IntCase.ControlSource = [IntCase]
    End Sub
    Last edited by Trudi; 02-16-04 at 17:48.

  5. #5
    Join Date
    Dec 2003
    Location
    Belfast, UK
    Posts
    87
    Fixed it!

    so stupid, the main form is a data entry so the search form should have been.


    stLinkCriteria = "[IntCase]=" & Me![txtCaseID]
    DoCmd.Close
    DoCmd.OpenForm "frmcase", , , stLinkCriteria,acformedit , , "Whatever"

    Silly how the tiniest bit of code can throw the entire thing out.

Posting Permissions

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