Default Value issues when opening form

lmcc007

Registered User.
Local time
Today, 13:50
Joined
Nov 10, 2007
Messages
635
I have an add form called fdlgEventDetailAdd and an edit form called fdlgEventDetailEdit, which is different. Then I have a note field in a separate table called fdlgEventNote. I created three forms for the note field because of the Default Value, which are below:

fdlgEventNoteAdd --- Default Value = [Forms]![fdlgEventDetailAdd]![txtEventID]

fdlgEventNoteAdd_2 --- Default Value =[Forms]![fdlgEventDetailEdit]![txtEventID]

fdlgEventNoteEdit --- Default Value =[Forms]![fdlgEventDetailEdit]![txtEventID]
Basically, I created the EventNoteAdd form to get it open to the correct EventID in add mode. That is, when adding an event while in fdlgEventDetailAdd form and you click to add a note, the Default Value = [Forms]![fdlgEventDetailAdd]![txtEventID].

I created the fdlgEventNoteAdd_2 form to get it to open to the correct EventID in add mode, when adding a note when you are in [Forms]![fdlgEventDetailEdit]![txtEventID].

Then I created fdlgEventNoteEdit form to work with fdlgEventDetailEdit. So, when you click the edit button to edit the current note for this record it will open correctly when the Default Value =[Forms]![fdlgEventDetailEdit]![txtEventID].

It seems like I have too many forms just for this one EventNote field.

What do you all think? Is there a better way? Why can't I have just one form--EventNote form?

Thanks for any suggestions.
 
It seems to me that all the distinctions between forms you've created are pretty subtle and are definitely things you could set in code or set when you open the form.
Maybe for starters read the whole article in Access help about Docmd.OpenForm. You can open a form in DataEntry (Add) mode or edit mode very easily. You can open a form so code execution is suspended until the form is closed. You can open a form to show a specific record or open a form with a specific filter. You can pass a string to the form so it can take custom actions when it opens or set the value of a control.
HTH
 
... read the whole article in Access help about Docmd.OpenForm...
HTH

Yep, I did. Their stuff is too technical for me. Anyway, no big deal on this one bc the forms work like it is. I was looking for a quick solution.
 
Well, here's one, dead simple, that opens the form in DataEntry mode ...
Code:
DoCmd.OpenForm "YourForm", , , , acFormAdd
Or this one to show all the records (Edit Mode) ...
Code:
DoCmd.OpenForm "YourForm", , , , acFormEdit
But I get you. "If it's not broken ... "
 
Well, here's one, dead simple, that opens the form in DataEntry mode ...
Code:
DoCmd.OpenForm "YourForm", , , , acFormAdd
Or this one to show all the records (Edit Mode) ...
Code:
DoCmd.OpenForm "YourForm", , , , acFormEdit
But I get you. "If it's not broken ... "

Ok, go ahead and laugh but I'm going to ask anyway. Is openArg the acFormAdd? Is that like saying when opening the form put it in date entry mode (add mode)?
 
Not sure what you mean by OpenArg. acFormAdd is the DataMode parameter of the DoCmd.OpenForm command and causes the form to open in DataEntry mode. The DoCmd.OpenForm command also has an OpenArgs parameter. If you specify a value for OpenArgs, the form that opens can read that value from its OpenArgs property. Consider the following code...
Code:
  DoCmd.OpenForm "FormName", , , , , , "This is the OpenArgs parameter"
Now, when the form FormName opens, it might contain code that does this ...
Code:
Private Sub Form_Open(Cancel As Integer)
  MsgBox Me.OpenArgs, vbInformation
End Sub
In that case a message box would open and display the text, "This is the OpenArgs parameter," which is pretty simple. In this way the code that opens a form can pass data to that form, which that form can then use to take some custom action, like maybe navigate to and show a particular record.
Cheers,
 
Not sure what you mean by OpenArg. acFormAdd is the DataMode parameter of the DoCmd.OpenForm command and causes the form to open in DataEntry mode. The DoCmd.OpenForm command also has an OpenArgs parameter. If you specify a value for OpenArgs, the form that opens can read that value from its OpenArgs property. Consider the following code...
Code:
  DoCmd.OpenForm "FormName", , , , , , "This is the OpenArgs parameter"
Now, when the form FormName opens, it might contain code that does this ...
Code:
Private Sub Form_Open(Cancel As Integer)
  MsgBox Me.OpenArgs, vbInformation
End Sub
In that case a message box would open and display the text, "This is the OpenArgs parameter," which is pretty simple. In this way the code that opens a form can pass data to that form, which that form can then use to take some custom action, like maybe navigate to and show a particular record.
Cheers,
I see stuff like "use your openArg to do this or that," which I didn't know what openArg meant.

You explanation is a littler clearer. I'll read it again tomorrow and hopefullly I'll get it better. It's been a long day.

Thanks!
 

Users who are viewing this thread

Back
Top Bottom