I've got a user form with the following
cboNewOrExist = combobox for selecting New Relationship or Existing Relationship
txtNewRel = text box for entering New relationship name.
cboExistRel = Combobox for selecting Existing Relationships
txtNewRel is only visible if cboNeworExist =New Relationship
cboExistRel is only visible if cboNeworExist = Existing Relationship
If cboNewOrExist = New Relationship and the AddAccount button is pressed I would like the following to happen
1. add the new relationship to the tblRelationships
2. ReQuery qryRelationship
3. hide txtNewRel text box
4. show cboExistRel combo box
5. cboNewOrExist = Existing Relationship
6. cboExistRel should be populated with the value just added to tblRelationships from txtNewRel. This value is in the qryRelationship with the highest RelationshipID number.
I've got 1-5 solved but I can't manage to change what the user sees in the cboExistRel
I've tried the following with no success
cboNewOrExist = combobox for selecting New Relationship or Existing Relationship
txtNewRel = text box for entering New relationship name.
cboExistRel = Combobox for selecting Existing Relationships
txtNewRel is only visible if cboNeworExist =New Relationship
cboExistRel is only visible if cboNeworExist = Existing Relationship
If cboNewOrExist = New Relationship and the AddAccount button is pressed I would like the following to happen
1. add the new relationship to the tblRelationships
2. ReQuery qryRelationship
3. hide txtNewRel text box
4. show cboExistRel combo box
5. cboNewOrExist = Existing Relationship
6. cboExistRel should be populated with the value just added to tblRelationships from txtNewRel. This value is in the qryRelationship with the highest RelationshipID number.
I've got 1-5 solved but I can't manage to change what the user sees in the cboExistRel
Code:
If Me!cboNewOrExist.Column(0) = "New Relationship" And Me!txtNewRel.Value <> vbNullString Then
strSQLRelationship = "INSERT INTO tblRelationships(Relationship) VALUES (Me!txtNewRel.Value);"
DoCmd.RunSQL strSQLRelationship
DoCmd.Requery (qryRelationship)
Me!txtNewRel.Visible = False
Me!cboExistRel.Visible = True
MaxRelationship = DMax("[tblRelationships.RelationshipID]", "qryRelationship")
Me!cboNewOrExist.Value = Me!cboNewOrExist.Column(0, 1)
Me!cboExistRel.Value = ????
End If
Code:
Me!cboExistRel.Value = txtNewRel.Value
Me!cboExistRel.Value = (DLookup("[Relationship]", "qryRelationship", "[tblRelationships.RelationshipID] =" & MaxRelationship))