Basic VBA

satty

Board Regular
Joined
Jan 12, 2003
Messages
68
hey people!

im currently havin a problem with VBA. i have a form from where the user can Add or Amend Customers. I have the following code to the Add button:

Private Sub AddNewCustomer_Click()
On Error GoTo Err_AddNewCustomer_Click

Dim stDocName As String
Dim stLinkCriteria As String

DoCmd.Close
stDocName = "Customer Details"
DoCmd.OpenForm stDocName, , , stLinkCriteria


Exit_AddNewCustomer_Click:
Exit Sub

Err_AddNewCustomer_Click:
MsgBox Err.Description
Resume Exit_AddNewCustomer_Click

End Sub


Howeve, i want the form to be in 'ADD MODE' when i click this button. how would i go about doing this? or is there an easier way? :p

Thanx Guys!


SaTTy
 

Excel Facts

Copy formula down without changing references
If you have =SUM(F2:F49) in F50; type Alt+' in F51 to copy =SUM(F2:F49) to F51, leaving the formula in edit mode. Change SUM to COUNT.
I don't have Access in front of me so can't give the exact syntax, but this line...

DoCmd.OpenForm stDocName, , , stLinkCriteria

...will accept the mode argument. In the module, retype that line and follow the prompts -- after one of the commas you will see drop-down options for acAdd, acEdit, and acReadOnly (or similar).

Denis
 
Upvote 0

Forum statistics

Threads
1,221,631
Messages
6,160,942
Members
451,679
Latest member
BlueH1

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