controls work fine in form but not if its used as as a subform?

Happy YN

Registered User.
Local time
Today, 11:39
Joined
Jan 27, 2002
Messages
425
I have code which fills in a textbox based on a value in another (popup)form. This works fine but if I have this form open as a subform then although the textbox receives the focus , it does not allow the value to be filled in
Code:
Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "ezx_TimeClock"
DoCmd.OpenForm stDocName, acNormal, , , , acDialog, Me.Name & ".[txttime]"
Me!TxtTime.SetFocus
I can edit the text box by hand but it refuses to accept the value passed to it by the code
Any ideas??
 
No reply in 24 hours!!! Whats going on!!

Just pushing this to the top as I need it solved
Briefly: My form is continuous, and controls allow editions of records.
But when I use the form as a subform the controls don't seem to gather the info to edit the relevant record
Anyone come across a subform refusing to work??
Thanks
 
Thanks Pat for your reply
I copied this code from elsewhere and it has always worked fine for me.
It basically opens a calendar or clock form where I can select a date or time and then when I close that form, the arguement if that is the right word for it, is passed back to the textbox which gets the focus.
As I said it works fine when the subform is on its own but when its being used as a subform somehow when the calendar form is closed it does not pass its arguement to the desired control
Thanks again
Happy YN
 
Help still required please!

I thought it may help to solve my problem if I post the code of the calendar form that takes the openargs part of it openform and then puts the date back into it by setting the focus to it
Code:
Private Sub Form_Close()
'if passed parameter then set date on control passed to selected date
Dim xForm As String, xControl As String
Dim i As Integer
    If IsNull(Me.OpenArgs) Then GoTo Done
    i = InStr(1, Me.OpenArgs, ".")
    xForm = Left(Me.OpenArgs, i - 1)
    xControl = Mid(Me.OpenArgs, i + 1)
    Forms(xForm)(xControl) = Me.DispDate
Done:
End Sub

So it takes the form name and finds the right textbox . But if the form is used as a subform it cannot identify it so how can I modify
Code:
    DoCmd.OpenForm stDocName, acNormal, , , , acDialog, Me.Name & ".[txttime]"

I tried referencing directly to the subform textbox
Code:
    DoCmd.OpenForm stDocName, acNormal, , , , acDialog, [Forms]![addgrades]![grade query subform].Form![TxtTime]
but that just produces errors
Any ideas anyone
Thanks
 
Last edited:

Users who are viewing this thread

Back
Top Bottom