Terri Hdokins
Registered User.
- Local time
- Today, 00:19
- Joined
- Jun 21, 2001
- Messages
- 15
I hope someone can help me because I am really stuck.
I have 2 problems.
1. Before I delete a table in Access and bring in a new one I have to
delete a relationship. At one time this code worked but now it is not.
Private Sub cmdRemove_Click()
Dim db As DAO.Database
Dim rel As DAO.Relation
On Error GoTo cmdRemove_Err
Set db = CurrentDb()
Set rel = db.Relations.Delete("Relation1")
cmdRemove_Exit:
Exit Sub
cmdRemove_Err:
MsgBox Error$
Resume cmdRemove_Exit
End Sub
2. Then after I delete the table and bring in the new one I want to create
the relationship. When I first run the following code I get the error
message "Object doesn't support this property or method." Then if I run it
again I get teh message "Object "Relation1" already exists." and suddenly
my relationship is created.
Private Sub cmdCreateRel_Click()
Dim db As DAO.Database
Dim rel As DAO.Relation
Dim fld As DAO.Field
On Error GoTo cmdCreateRel_Err
Set db = CurrentDb()
Set rel = db.CreateRelation("Relation1", "tblFieldMaster", "tblSalesDetail",
dbRelationLeft)
Set fld = rel.CreateField("RanchPlot")
fld.ForeignName = "RanchPlot"
rel.Fields.Append fld
db.Relations.Append rel
cmdCreateRel = True
cmdCreateRel_Exit:
Exit Sub
cmdCreateRel_Err:
MsgBox Error$
Resume cmdCreateRel_Exit
End Sub
Does anyone have any suggestions????
I really need help.
Thanks,
Terri Hodkins
I have 2 problems.
1. Before I delete a table in Access and bring in a new one I have to
delete a relationship. At one time this code worked but now it is not.
Private Sub cmdRemove_Click()
Dim db As DAO.Database
Dim rel As DAO.Relation
On Error GoTo cmdRemove_Err
Set db = CurrentDb()
Set rel = db.Relations.Delete("Relation1")
cmdRemove_Exit:
Exit Sub
cmdRemove_Err:
MsgBox Error$
Resume cmdRemove_Exit
End Sub
2. Then after I delete the table and bring in the new one I want to create
the relationship. When I first run the following code I get the error
message "Object doesn't support this property or method." Then if I run it
again I get teh message "Object "Relation1" already exists." and suddenly
my relationship is created.
Private Sub cmdCreateRel_Click()
Dim db As DAO.Database
Dim rel As DAO.Relation
Dim fld As DAO.Field
On Error GoTo cmdCreateRel_Err
Set db = CurrentDb()
Set rel = db.CreateRelation("Relation1", "tblFieldMaster", "tblSalesDetail",
dbRelationLeft)
Set fld = rel.CreateField("RanchPlot")
fld.ForeignName = "RanchPlot"
rel.Fields.Append fld
db.Relations.Append rel
cmdCreateRel = True
cmdCreateRel_Exit:
Exit Sub
cmdCreateRel_Err:
MsgBox Error$
Resume cmdCreateRel_Exit
End Sub
Does anyone have any suggestions????
I really need help.
Thanks,
Terri Hodkins