VBA - ShowDataForm and add new record

Jasesair

Active Member
Joined
Apr 8, 2015
Messages
282
Office Version
  1. 2016
I have the below code for Showing the Data Form and am just after a little extra for it to open the Data Form to a new record. Any help would be fantastic.

VBA Code:
Sub ShowDataForm()
    With Sheets("Weekly Entry")
        .Select
        .ShowDataForm
    End With
    Sheets("Database").Activate
End Sub
 

Excel Facts

Pivot Table Drill Down
Double-click any number in a pivot table to create a new report showing all detail rows that make up that number
See if this works for you :
VBA Code:
Sub ShowDataForm()
    With Sheets("Weekly Entry")
        .Select
        Application.SendKeys ("%w")
        DoEvents
        Application.SendKeys ("%w")
        .ShowDataForm
    End With
    Sheets("Database").Activate
End Sub
 
Upvote 0
See if this works for you :
VBA Code:
Sub ShowDataForm()
    With Sheets("Weekly Entry")
        .Select
        Application.SendKeys ("%w")
        DoEvents
        Application.SendKeys ("%w")
        .ShowDataForm
    End With
    Sheets("Database").Activate
End Sub
No sorry, that didn't seem to work at all. It actually stopped the Data Form from actually opening - just took me to the sheet.
 
Upvote 0
It worked for me.

How are you calling the ShowDataForm sub ? from a button , an event, ribbon etc ?

Can you upload a copy of your workbook so we can take a look ?
 
Upvote 0
I'm just assigning this macro to a self-created button. With the initial macro (in its own module), it works perfectly. I'm just keen for it not to open the Data Form to be displaying the first entry, but to open to a new entry.
 
Upvote 0
I'm just assigning this macro to a self-created button. With the initial macro (in its own module), it works perfectly. I'm just keen for it not to open the Data Form to be displaying the first entry, but to open to a new entry.
That's exacltly what I did when testing and worked just fine for me.

Is the letter w the accelerator key for the New button in the dataform ? Does pressing Alt+W activate the new record button ?
 
Upvote 0

Forum statistics

Threads
1,214,923
Messages
6,122,286
Members
449,076
Latest member
kenyanscott

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top