View Single Post
  #5  
Old September 10th, 2009, 03:21 AM posted to microsoft.public.access.tablesdbdesign
Ken Snell [MVP]
external usenet poster
 
Posts: 279
Default Replace form in external mdb

You can use code such as this to test if the form is the

Dim aca As Access.Application
Dim frm As Form
Dim intReply As Integer
Set aca = New Access.Application
aca.OpenCurrentDatabase "C:\MyFolder\MyDBmdb"
intReply = vbYes
For Each frm In aca.CurrentProject.AllForms
If frm.Name = "NameOfFormInOtherDB" Then
intReply = MsgBox("Form exists. Do you want to replace it?", _
vbYesNo, "Replace Form?")
Exit For
End If
Next frm
aca.CloseCurrentDatabase
aca.Quit
Set aca = Nothing
If intReply = vbYes Then
DoCmd.TransferDatabase acExport, "Microsoft Access",
"C:\MyFolder\MyDBmdb", _
acForm, "NameOfFormInYourDB", "NameOfFormInOtherDB"
End If


--

Ken Snell
MS ACCESS MVP
http://www.accessmvp.com/KDSnell/


--

Ken Snell
MS ACCESS MVP
http://www.accessmvp.com/KDSnell/




"AndrewDB" wrote in message
...
Thanks Ken. If the form already exists in that database I need a message
informing me so that I can respond -Replace? Yes/No. If yes I need to
first
delete the original form before copying the new one across.

By the way what does [MVP] stand for?

Best Regards

--
Kepior Senso Fumor


"Ken Snell [MVP]" wrote:

Check out DoCmd.TransferDatabase method in VBA.

--

Ken Snell
MS ACCESS MVP
http://www.accessmvp.com/KDSnell/


"AndrewDB" wrote in message
...
Hi All. I need to replace a form and attached vb procedures situated in
an
external mdb using vba. I can use copyobject but as a form with that
name
already exists I get an error.

--
Kepior Senso Fumor