This is the code I'm using to change my table's data. tblParts name dosen't change, only the data, PartsName_global is the table name from a combobox.
All this works for me untill I add relationships to my tblParts.
Is there any way around this, without deleting relationships? Looking for options! Form used to setup database.
Thanks!
Code:
Private Sub cmdReloadParts_Click() 'reload table tblPartsOn Error Resume Next
DoCmd.Close acForm, "frmParts" 'close all forms
DoCmd.Close acForm, "frmBuild"
DoCmd.Close acForm, "frmSearch"
DoCmd.Close acForm, "frmHelp"
DoCmd.Close acForm, "frmColorCode"
If IsNull(Me.Combo10) Then 'check if Combox is emply
MsgBox "You must choose Table in combobox below"
Exit Sub
End If
If Not IsNull(Me.Combo10) Then 'add Combox name to PartsName_global
PartsName_global = Me.Combo10
MsgBox PartsName_global
Else
'MsgBox "Enter Table"
End If
If PartsName_global = "tblParts" Then 'check if Combox is emply
MsgBox "Can't use this table! This table is loaded!" & vbCrLf & "Select another table from combo box!"
Exit Sub
End If
If TableExists(Me.Combo10) = True Then 'check if table exist, exit if no table
'MsgBox "valid Table"
Else
'MsgBox "Not a valid Table"
Exit Sub
End If
Dim OutPut As Integer
OutPut = MsgBox("Do you want to replace Table?" & vbCrLf & "Do you want to continue?", vbOKCancel + vbQuestion + vbDefaultButton2)
If OutPut = 1 Then
'MsgBox PartsName_global
Else
Exit Sub
End If
DoCmd.CopyObject , "tblParts", acTable, PartsName_global ' copy PartsName_global to tblParts from combox selection
End Sub