Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.databases.ms-access > #11954 > unrolled thread
| Started by | croy <croy@invalid.net> |
|---|---|
| First post | 2016-08-01 12:32 -0700 |
| Last post | 2016-08-17 14:33 -0700 |
| Articles | 12 — 5 participants |
Back to article view | Back to comp.databases.ms-access
OpenArgs Again croy <croy@invalid.net> - 2016-08-01 12:32 -0700
Re: OpenArgs Again Mike P <mikewpayne@tiscali.co.uk> - 2016-08-02 10:09 -0700
Re: OpenArgs Again croy <croy@invalid.net> - 2016-08-02 11:48 -0700
Re: OpenArgs Again croy <croy@invalid.net> - 2016-08-02 12:03 -0700
Re: OpenArgs Again Patrick Finucane <patrickfinucanetx@gmail.com> - 2016-08-03 16:03 -0700
Re: OpenArgs Again croy <croy@invalid.net> - 2016-08-16 08:12 -0700
Re: OpenArgs Again Patrick Finucane <patrickfinucanetx@gmail.com> - 2016-08-16 15:17 -0700
Re: OpenArgs Again Mike P <mikewpayne@tiscali.co.uk> - 2016-08-17 06:33 -0700
Re: OpenArgs Again pstanton54@gmail.com - 2016-08-16 23:40 -0700
Re: OpenArgs Again Patrick Finucane <patrickfinucanetx@gmail.com> - 2016-08-17 05:51 -0700
Re: OpenArgs Again Ulrich Möller <knobbi38@arcor.de> - 2016-08-17 19:05 +0200
Re: OpenArgs Again pstanton54@gmail.com - 2016-08-17 14:33 -0700
| From | croy <croy@invalid.net> |
|---|---|
| Date | 2016-08-01 12:32 -0700 |
| Subject | OpenArgs Again |
| Message-ID | <8i8vpbpkscdt5n7u1i7rc694galnre2ng8@4ax.com> |
Can OpenArgs be used to set a DefaultValue of a control on the form being opened? I've been able to enter a value with OpenArgs, but it dirties the record, which I'd rather not do just yet. When I adjust the Form's OnCurrent code to set the *DefaultValue*, the control then displays, "#Name?" when the form is opened. Possibly a timing issue? -- croy
[toc] | [next] | [standalone]
| From | Mike P <mikewpayne@tiscali.co.uk> |
|---|---|
| Date | 2016-08-02 10:09 -0700 |
| Message-ID | <e7d1acb5-ffd2-402c-abd3-eff4ba3f7c5d@googlegroups.com> |
| In reply to | #11954 |
On Monday, August 1, 2016 at 8:32:05 PM UTC+1, croy wrote: > Can OpenArgs be used to set a DefaultValue of a control on > the form being opened? > > I've been able to enter a value with OpenArgs, but it > dirties the record, which I'd rather not do just yet. When > I adjust the Form's OnCurrent code to set the > *DefaultValue*, the control then displays, "#Name?" when the > form is opened. > > Possibly a timing issue? > > -- > croy Hi Croy, Could you set the *DefaultValue* in the Before Update event of the form? Presumably only do this if the control is Null. Mike P. 2/8/16
[toc] | [prev] | [next] | [standalone]
| From | croy <croy@invalid.net> |
|---|---|
| Date | 2016-08-02 11:48 -0700 |
| Message-ID | <tgq1qbps2nfg3gpu7bmvrn4eluuam568ga@4ax.com> |
| In reply to | #11955 |
On Tue, 2 Aug 2016 10:09:01 -0700 (PDT), Mike P <mikewpayne@tiscali.co.uk> wrote: >On Monday, August 1, 2016 at 8:32:05 PM UTC+1, croy wrote: >> Can OpenArgs be used to set a DefaultValue of a control on >> the form being opened? >> >> I've been able to enter a value with OpenArgs, but it >> dirties the record, which I'd rather not do just yet. When >> I adjust the Form's OnCurrent code to set the >> *DefaultValue*, the control then displays, "#Name?" when the >> form is opened. >> >> Possibly a timing issue? >> >> -- >> croy > >Hi Croy, > >Could you set the *DefaultValue* in the Before Update event of the form? Presumably only do this if the control is Null. That works, but doesn't show the value from the parent form until the record is dirty. I'd prefer to have the parent form value showing in the newly opened form, like a default value would do, without making the record dirty. It just looks more comforting to the data-entry clerk. -- croy
[toc] | [prev] | [next] | [standalone]
| From | croy <croy@invalid.net> |
|---|---|
| Date | 2016-08-02 12:03 -0700 |
| Message-ID | <0br1qb53rll1bqfehrccejd87jgae2hv2v@4ax.com> |
| In reply to | #11956 |
On Tue, 02 Aug 2016 11:48:09 -0700, croy <croy@invalid.net> wrote: >On Tue, 2 Aug 2016 10:09:01 -0700 (PDT), Mike P ><mikewpayne@tiscali.co.uk> wrote: > >>On Monday, August 1, 2016 at 8:32:05 PM UTC+1, croy wrote: >>> Can OpenArgs be used to set a DefaultValue of a control on >>> the form being opened? >>> >>> I've been able to enter a value with OpenArgs, but it >>> dirties the record, which I'd rather not do just yet. When >>> I adjust the Form's OnCurrent code to set the >>> *DefaultValue*, the control then displays, "#Name?" when the >>> form is opened. >>> >>> Possibly a timing issue? >>> >>> -- >>> croy >> >>Hi Croy, >> >>Could you set the *DefaultValue* in the Before Update event of the form? Presumably only do this if the control is Null. > >That works, but doesn't show the value from the parent form >until the record is dirty. I'd prefer to have the parent >form value showing in the newly opened form, like a default >value would do, without making the record dirty. It just >looks more comforting to the data-entry clerk. I lied--that doesn't work. I still get "#Name?" for that field. What works is simply putting the parent form control in the Default Value of the property sheet for that control on the newly-opened form, like, "=[Forms]![frmDEAll]![txtArchId]". Since this form will only be opened from the one parent form, I guess this is ok. -- croy
[toc] | [prev] | [next] | [standalone]
| From | Patrick Finucane <patrickfinucanetx@gmail.com> |
|---|---|
| Date | 2016-08-03 16:03 -0700 |
| Message-ID | <aa5bc580-ab48-4b37-a9f3-2d176fede120@googlegroups.com> |
| In reply to | #11954 |
On Monday, August 1, 2016 at 3:32:05 PM UTC-4, croy wrote: > Can OpenArgs be used to set a DefaultValue of a control on > the form being opened? > > I've been able to enter a value with OpenArgs, but it > dirties the record, which I'd rather not do just yet. When > I adjust the Form's OnCurrent code to set the > *DefaultValue*, the control then displays, "#Name?" when the > form is opened. > > Possibly a timing issue? > > -- > croy Here's a simple test. Create a form on a junk table. let's say the junk table has a field dt. Set the default value to =Date(). open the form. go to a new record. I'd assume it's dirty from the get go as the default value has updated the dirty status.
[toc] | [prev] | [next] | [standalone]
| From | croy <croy@invalid.net> |
|---|---|
| Date | 2016-08-16 08:12 -0700 |
| Message-ID | <lsa6rb180ghjlpk2me0419vhpr2bb2asnm@4ax.com> |
| In reply to | #11959 |
On Wed, 3 Aug 2016 16:03:37 -0700 (PDT), Patrick Finucane <patrickfinucanetx@gmail.com> wrote: >On Monday, August 1, 2016 at 3:32:05 PM UTC-4, croy wrote: >> Can OpenArgs be used to set a DefaultValue of a control on >> the form being opened? >> >> I've been able to enter a value with OpenArgs, but it >> dirties the record, which I'd rather not do just yet. When >> I adjust the Form's OnCurrent code to set the >> *DefaultValue*, the control then displays, "#Name?" when the >> form is opened. >> >> Possibly a timing issue? >> >> -- >> croy > >Here's a simple test. Create a form on a junk table. let's say the junk table has a field dt. Set the default value to =Date(). > >open the form. go to a new record. I'd assume it's dirty from the get go as the default value has updated the dirty status. Thanks for the reply. Nope. Today's date shows, but the record is not dirty. I put the default in the control's property sheet as you indicated above. Is there a way to use the property sheet to set the default for the control to OpenArgs? I've tried (=OpenArgs), but can't seem to get it working. -- tbl
[toc] | [prev] | [next] | [standalone]
| From | Patrick Finucane <patrickfinucanetx@gmail.com> |
|---|---|
| Date | 2016-08-16 15:17 -0700 |
| Message-ID | <92d82005-3bb5-484c-92f8-77474f0c8b38@googlegroups.com> |
| In reply to | #11970 |
On Tuesday, August 16, 2016 at 11:12:38 AM UTC-4, croy wrote: > On Wed, 3 Aug 2016 16:03:37 -0700 (PDT), Patrick Finucane > <patrickfinucanetx@gmail.com> wrote: > > >On Monday, August 1, 2016 at 3:32:05 PM UTC-4, croy wrote: > >> Can OpenArgs be used to set a DefaultValue of a control on > >> the form being opened? > >> > >> I've been able to enter a value with OpenArgs, but it > >> dirties the record, which I'd rather not do just yet. When > >> I adjust the Form's OnCurrent code to set the > >> *DefaultValue*, the control then displays, "#Name?" when the > >> form is opened. > >> > >> Possibly a timing issue? > >> > >> -- > >> croy > > > >Here's a simple test. Create a form on a junk table. let's say the junk table has a field dt. Set the default value to =Date(). > > > >open the form. go to a new record. I'd assume it's dirty from the get go as the default value has updated the dirty status. > > Thanks for the reply. > > Nope. Today's date shows, but the record is not dirty. I > put the default in the control's property sheet as you > indicated above. > > Is there a way to use the property sheet to set the default > for the control to OpenArgs? I've tried (=OpenArgs), but > can't seem to get it working. > > -- > tbl Try =OpenArgs() instead as OpenArgs is like a function. You could set the openargs() value to a Tempvar. Ex: Tempvars.add "openingdefault", Me.Openargs.value n the onOpen event and in the Default enter tempvars!openingdefault.value it may or may not work.
[toc] | [prev] | [next] | [standalone]
| From | Mike P <mikewpayne@tiscali.co.uk> |
|---|---|
| Date | 2016-08-17 06:33 -0700 |
| Message-ID | <ea563c8f-765c-4758-aac7-f3103da3837d@googlegroups.com> |
| In reply to | #11970 |
On Tuesday, August 16, 2016 at 4:12:38 PM UTC+1, croy wrote: > On Wed, 3 Aug 2016 16:03:37 -0700 (PDT), Patrick Finucane > <patrickfinucanetx@gmail.com> wrote: > > >On Monday, August 1, 2016 at 3:32:05 PM UTC-4, croy wrote: > >> Can OpenArgs be used to set a DefaultValue of a control on > >> the form being opened? > >> > >> I've been able to enter a value with OpenArgs, but it > >> dirties the record, which I'd rather not do just yet. When > >> I adjust the Form's OnCurrent code to set the > >> *DefaultValue*, the control then displays, "#Name?" when the > >> form is opened. > >> > >> Possibly a timing issue? > >> > >> -- > >> croy > > > >Here's a simple test. Create a form on a junk table. let's say the junk table has a field dt. Set the default value to =Date(). > > > >open the form. go to a new record. I'd assume it's dirty from the get go as the default value has updated the dirty status. > > Thanks for the reply. > > Nope. Today's date shows, but the record is not dirty. I > put the default in the control's property sheet as you > indicated above. > > Is there a way to use the property sheet to set the default > for the control to OpenArgs? I've tried (=OpenArgs), but > can't seem to get it working. > > -- > tbl =[OpenArgs] as the default value works for me, in a bound or unbound control. Note the square brackets. Could you explain how you are opening the form that uses OpenArgs? Presumably Docmd.OpenForm. What arguments are you using? Mike P. 17/8/16
[toc] | [prev] | [next] | [standalone]
| From | pstanton54@gmail.com |
|---|---|
| Date | 2016-08-16 23:40 -0700 |
| Message-ID | <ba188a56-2779-442c-95fd-95ec3d70e351@googlegroups.com> |
| In reply to | #11954 |
On Monday, 1 August 2016 20:32:05 UTC+1, croy wrote:
> Can OpenArgs be used to set a DefaultValue of a control on
> the form being opened?
>
> I've been able to enter a value with OpenArgs, but it
> dirties the record, which I'd rather not do just yet. When
> I adjust the Form's OnCurrent code to set the
> *DefaultValue*, the control then displays, "#Name?" when the
> form is opened.
>
> Possibly a timing issue?
>
> --
> croy
This is a bit complicated, but I'll try to explain.
A lot of reports need a "from" & "to" range input, and there appear to be a number of ways of entering this information from using parameters in the underlying query or using an input box or having a dedicated form to input the range.
My approach is to have a single input form that is "Customised" by the report to ask for the correct information. The form has a to & from Combo box and a to & from text box.
I won't go into the full details, but here is the gist of it. Actually I pass 32 bits of information to "Customise" the form.
rivate Sub Report_Open(Cancel As Integer)
Dim ArgsOut As String
ArgsOut = Me.Name ' 1) Calling report
ArgsOut = ArgsOut & "~-32764" ' 2) -32764 (= report type)
ArgsOut = ArgsOut & "~1" ' 3) No of combo box sets needed
ArgsOut = ArgsOut & "~Branch Statistics " ' 4) Start of title
ArgsOut = ArgsOut & "~Enter Branch Range <All> = All, and Date Range" ' 5) Prompt
ArgsOut = ArgsOut & "~" ' 6) From Value
ArgsOut = ArgsOut & "~" ' 7) To Value
' Combo Box setup
ArgsOut = ArgsOut & "~Branch" ' 8) Combo Filter Field
ArgsOut = ArgsOut & "~Branches" ' 9) Combo Not in order message
ArgsOut = ArgsOut & "~From Branch" ' 10) Combo From Label
ArgsOut = ArgsOut & "~To Branch" ' 11) Combo To Label
ArgsOut = ArgsOut & "~" ' 12) Combo Format of Combo box
ArgsOut = ArgsOut & "~0" ' 13) Combo Decimal places
ArgsOut = ArgsOut & "~-1" ' 14) Combo LimitToList
ArgsOut = ArgsOut & "~2800" ' 15) Combo Width
ArgsOut = ArgsOut & "~1" ' 16) Combo Bound Column
ArgsOut = ArgsOut & "~2" ' 17) Combo Column Count
ArgsOut = ArgsOut & "~2800;0" ' 18) Combo Column Widths
ArgsOut = ArgsOut & "~2800" ' 19) Combo List Width
' 20) First Combo Default Value"
ArgsOut = ArgsOut & "~'" & DLookup("Branch", "QBranchForComputer", "ComputerName = '" & fOSMachineName() & "'") & "'"
' 21) Second Combo Default Value"
ArgsOut = ArgsOut & "~'" & DLookup("Branch", "QBranchForComputer", "ComputerName = '" & fOSMachineName() & "'") & "'"
' 22) SQL for Combo Boxes
ArgsOut = ArgsOut & "~SELECT " & Chr$(34) & "<All>" & Chr$(34) & " AS Branch, 0 AS BranchID, 0 AS SortOrder FROM TblBranch "
ArgsOut = ArgsOut & "UNION SELECT TblBranch.Branch, BranchID, Branch as SortOrder FROM TblBranch "
ArgsOut = ArgsOut & "WHERE Nz(Branch) > '' ORDER BY SortOrder, Branch;"
Then we open the form
Private Sub Form_Open(Cancel As Integer)
Dim Args As String
Args = Nz(Me.OpenArgs)
If Args = "" Then
Exit Sub
End If
' 19 lines here
CboFromField1.DefaultValue = ExtractStrings(Args, "~", 20) ' 20) First Combo Default Value
CboToField1.DefaultValue = ExtractStrings(Args, "~", 21) ' 21) First Combo Default Value
and this is the routine to extract the information from the OpenArgs
Public Function ExtractStrings(MyText As String, Delim As String, GroupNum As Integer) As String
' Returns a group extract from a string via a delimter.
' Hence to grab "cat" from the string dog-cat you get:
' ExtractStrings("dog-cat","-",2) = "cat"
Dim StartPos As Integer, EndPos As Integer
Dim GroupPtr As Integer, Chptr As Integer
Chptr = 1
StartPos = 0
For GroupPtr = 1 To GroupNum - 1
Chptr = InStr(Chptr, MyText, Delim)
If Chptr = 0 Then
ExtractStrings = ""
Exit Function
Else
Chptr = Chptr + 1
End If
Next GroupPtr
StartPos = Chptr
If MID(MyText, StartPos, 1) = Delim Then
ExtractStrings = ""
Else
EndPos = InStr(StartPos + 1, MyText, Delim)
If EndPos = 0 Then
EndPos = Len(MyText) + 1
End If
ExtractStrings = MID$(MyText, StartPos, EndPos - StartPos)
End If
End Function
The customised Form doesn't appear to be dirty.
Phil
[toc] | [prev] | [next] | [standalone]
| From | Patrick Finucane <patrickfinucanetx@gmail.com> |
|---|---|
| Date | 2016-08-17 05:51 -0700 |
| Message-ID | <5f09cf10-ddcc-4c44-a252-78244c827ade@googlegroups.com> |
| In reply to | #11954 |
On Monday, August 1, 2016 at 3:32:05 PM UTC-4, croy wrote: > Can OpenArgs be used to set a DefaultValue of a control on > the form being opened? > > I've been able to enter a value with OpenArgs, but it > dirties the record, which I'd rather not do just yet. When > I adjust the Form's OnCurrent code to set the > *DefaultValue*, the control then displays, "#Name?" when the > form is opened. > > Possibly a timing issue? > > -- > croy In extractstring you can use Split() and throw the results into an array. much quicker and easier. This does not address your issue tho.
[toc] | [prev] | [next] | [standalone]
| From | Ulrich Möller <knobbi38@arcor.de> |
|---|---|
| Date | 2016-08-17 19:05 +0200 |
| Message-ID | <np25fv$cs$1@dont-email.me> |
| In reply to | #11954 |
Hi Croy, Am 01.08.2016 um 21:32 schrieb croy: > Can OpenArgs be used to set a DefaultValue of a control on > the form being opened? > > I've been able to enter a value with OpenArgs, but it > dirties the record, which I'd rather not do just yet. When > I adjust the Form's OnCurrent code to set the > *DefaultValue*, the control then displays, "#Name?" when the > form is opened. > > Possibly a timing issue? > no timing issues! If you want to assign a value to a control's defaultvalue property in vba ms access evaluate the value as an expression which normally results in a display of "#name?". E.x. assign a string like "OnLoad" and you'll get the display "[Event Procedure]". So to overcome this problem just surround the string with single quotes. here is a short code snipped: Private Sub Form_Load() Debug.Print "Form_Load() ["; Me.OpenArgs; "]" Me!txtFilterDescription.DefaultValue = "'" & Me.OpenArgs & "'" End Sub Keep in mind if OpenArgs contains single or double quotes you have to escape this quotes as you would normally do this for each other expression. Ulrich
[toc] | [prev] | [next] | [standalone]
| From | pstanton54@gmail.com |
|---|---|
| Date | 2016-08-17 14:33 -0700 |
| Message-ID | <e5002edf-b475-4d60-8b0a-d9db7ea7d127@googlegroups.com> |
| In reply to | #11954 |
On Monday, 1 August 2016 20:32:05 UTC+1, croy wrote: > Can OpenArgs be used to set a DefaultValue of a control on > the form being opened? > > I've been able to enter a value with OpenArgs, but it > dirties the record, which I'd rather not do just yet. When > I adjust the Form's OnCurrent code to set the > *DefaultValue*, the control then displays, "#Name?" when the > form is opened. > > Possibly a timing issue? > > -- > croy This is addressed to Patrick's suggestion of using the Split function. Certainly hadn't thought of using it, and it certainly looks simple. Haven't I still got the same palaver to extract everything from the array though? Phil
[toc] | [prev] | [standalone]
Back to top | Article view | comp.databases.ms-access
csiph-web