dynamic popup screen for multiple comments fields

B

bu

I have a form with a handful of comments fields. I am trying to code the
form in such a way that when the user clicks on the field, a dialog box will
open up displaying the full contents of the field. I want to reuse the same
window for each field ( seems sensless to code a screen n times for n fields
when the only thing that is really changing is the source data ), but am
having all sorts of issues. I have tried dynamically setting the popup
windows RecordSource and Filter properties and the text field in the popup
to the correct ControlSource, but the data always displays the first record
in the table - it seems to ignore the Filter property - and I have tried
requery, refresh, etc.

What is the best way to do this? Certainly it has been done before?

Thanks in advance for any help you can provide!
Bill
 
S

Sergey Poberezovskiy

In your OnEnter event for your comments textboxes you can
add a call to a sub:

Private Sub txtCommentN_Enter()
openDialog(txtCommentN)
End Sub

and then

Public Sub openDialog(ByVal txt As TextBox)
If Not IsNull(txt) Then
DoCmd.OpenForm "MyDialogForm", WindowMode:=acDialog,
OpenArgs:=txt
End If
End Sub

and finally in MyDialogForm load event you can read
OpenArgs (string) argument:

Private Sub Form_Load()
If Not IsNull(OpenArgs) Then
MyReadOnlyTextBox = OpenArgs
End If
End Sub

HTH
 
B

bu

I should have added one more detail... if the user changes the data in the
popup, it should be passed back to the calling field.... :-(

thx,
bill
 
S

Sergey Poberezovskiy

Not a worry: just modify a few things:

Public Sub openDialog(ByVal txt As TextBox)
Const formName As String = "MyDialogForm"
If Not IsNull(txt) Then
DoCmd.OpenForm formName, WindowMode:=acDialog,
OpenArgs:=txt
If SysCmd(acSysCmdGetObjectState, acForm, formName)
And acObjStateOpen Then
txt = Forms(formName)!MyNotReadOnlyAnyMoreTextBox
DoCmd.Close acForm, formName
End
End If
End Sub

and within MyDialogForm on Close (or Exit) button click
just make it invisible instead of closing it. On Cancel
button you can close the form.

HTH
 
B

bu

thanks for the reply and help, but I found a much easier way to do it:

DoCmd.RunCommand acCmdZoomBox

thx,
B
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top