0

I am creating a database with many forms within it where frequently i require a "zoom in box" to open a field on a record and allow the user to enter long lines of text into a 'memo' field. At the moment due to my limited vba programming knowledge, I am forced to create a new (and identical) zoom in form for each field where I would like to zoom in on. I am wondering if it is possible to NOT have to create a new form each time i want to do this but to only have one standard 'zoom-in' form which knows which table/field is being accessed.

1 Answer 1

1

I assume you have same table and just wanting to change field name , in case the table name and field also changed, we can write the logic for the same with sample code below.

When opening the form you need to know which field needs to be used. There is facility in Microsoft Access VBA when opening a form, we can pass OpenArgs. This OpenArgs can be used as a way to understand which field to set the zoom form.

'Code when the zoom button clicked
DoCmd.OpenForm "frmZoom", , , , , , "memoField1"

Write code for each of the desired button, so you can pass which field to use for the zoom form.

The open event of Zoom form will have following code

'Check which field we need to set for the memo field
Select Case Me.OpenArgs 
Case "memoField1"
    Me.tbMemoField1.ControlSource="memoField1"
Case "memoField2"
    Me.tbMemoField2.ControlSource="memoField2"
End Select

Replace the field names and control names as per your needs above.

Sign up to request clarification or add additional context in comments.

2 Comments

No that is not correct. Unfortunately, they are all different underlying tables.. I need to find a way so when the form closes, it runs a routine to identify from which table the data comes from.
When do you know which table and field be used for updating the memo field ? If its after user selects some control or drop-down etc. You can write above code on the control's after update event. And write additional code for setting table as well Me.RecordSource="<Table Name>" . And if you don't know which table to use till you close the Zoom form , we need to write SQL or open recordset to update data to related table, field.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.