PDA

View Full Version : Solved: VBA code or Macro code



gsanghvi20
07-29-2008, 11:21 AM
Hi guys,
Please :help
On form load I want 2 things to happen.
1) One of the txtboxes should take the value of another txt of another form.
2) The bound txtboxes should point to a New record.

I know the VBA code for 1st:
AddManagerName.Value = Forms![frmViewManager]![ViewGoTo]
And know the Macro code for the 2nd:
GoToRecord > New

How do I achieve both using either VBA or Macro.

Thanks,
gsanghvi20

CreganTur
07-29-2008, 11:36 AM
Welcome to the forum! Always good to see new faces.

Open your form in Design view and open up your properties sheet. There's a little box in the top, left corner of the design-viewed form- make sure that you click on it (you should see a little black box inside it now)- this will open up the Form properties.

Now, on the properties window, click on the Event tab and select the On Load event- you'll need to click the build button (...), and make certain you select Code Window if prompted.

This will open up the VBE, and you'll be presented with the code wrapper for the On Load Event:
Private Sub Form_Load()
End Sub

Now you can just add the code you want to run when the Form loads into this wrapper:
Private Sub Form_Load()
AddManagerName.Value = Forms![frmViewManager]![ViewGoTo]
End Sub

Regarding the 'new record' part of your question, I'd like to ask this: are you wanting this form to be a data-entry only form? If so, then you don't need to use VBA to move to the new record. Go back to the properties sheet for the form and, under the Data tab, set Data Entry to Yes. This turns your form into a Data Entry form, which can be used only to add new records to a table.

gsanghvi20
07-29-2008, 11:46 AM
Thanks. I figured it out.:content: