Results 1 to 3 of 3
  1. #1
    Join Date
    May 2004
    Posts
    63

    Unanswered: Use Combo Box to add new record....pls help

    Ok now i have combo box problem :

    I have frmSite which has sfrmStudy.........for each site i can have more then one study and my sfrmStudy is singleform so it displays one study at time. Now on sfrmStudy i have combo box for user to select the study and then all other fields in sfrmStudy is related to combo box where user selects study

    Ex: for Study i have combo box "cboStudy".......next field is name of the study so its rowsource is.....=cboStudy.Column(1).

    All this works fine for me to navigate the record. But i don't understand what to do if user select the Site and then Study which is already exist in other site but user would like to add that study for diff site ? Do i need another form for that. ? I have been trying to figure this out from long time and i'm sure someone has easy solution to this.

    I have attached the db
    Attached Files Attached Files

  2. #2
    Join Date
    Feb 2004
    Posts
    533
    Quote Originally Posted by SAK2004
    All this works fine for me to navigate the record. But i don't understand what to do if user select the Site and then Study which is already exist in other site but user would like to add that study for diff site ? Do i need another form for that. ? I have been trying to figure this out from long time and i'm sure someone has easy solution to this.
    You can set a combined key for the table 'tblStudyInformation' using the 'StudyNo' and 'SiteNo'. If you try to enter the same combination twice for SiteNo/StudyNo access will give an Error and not allow the entry.

    You can use the same form which is easiest, or create a data entry form. You may want to preload some values form the previous record prior to the user clicking 'New' to add a record. Here's code where you can capture the previous value in a module level variable then use it if on a New Record.
    Code:
    Dim PrevSite As String
    
    Private Sub Form_Current()
        If Me.NewRecord Then
            If Not IsEmpty(PrevSite) Then
               Me.SiteName = PrevSite
            End If
        End If
        
        PrevSite = Nz(Me.SiteName, "")
    End Sub
    ~

    Bill

  3. #3
    Join Date
    May 2004
    Posts
    63
    savbill,

    Thanks for the response.

    But is there a way that when user want to enter Study for the new site they can see all available study in the combo box and if user wants to add any of those study to the new site they can do that or enter new study which is not in combo box ?

Posting Permissions

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