If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Replace form in external mdb
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 |
#2
|
|||
|
|||
Replace form in external mdb
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 |
#3
|
|||
|
|||
Replace form in external mdb
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 |
#4
|
|||
|
|||
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 |
#5
|
|||
|
|||
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 |
#6
|
|||
|
|||
Replace form in external mdb
"AndrewDB" wrote in message
... By the way what does [MVP] stand for? MVP is an award from Microsoft for people who are strongly involved in Microsoft Community. http://mvp.support.microsoft.com/ https://mvp.support.microsoft.com/profile/Kenneth.Snell -- Ken Snell MS ACCESS MVP http://www.accessmvp.com/KDSnell/ |
#7
|
|||
|
|||
Replace form in external mdb
"AndrewDB" wrote in message
... By the way what does [MVP] stand for? MVP is an award from Microsoft for people who are strongly involved in Microsoft Community. http://mvp.support.microsoft.com/ https://mvp.support.microsoft.com/profile/Kenneth.Snell -- Ken Snell MS ACCESS MVP http://www.accessmvp.com/KDSnell/ |
Thread Tools | |
Display Modes | |
|
|