Discussion Locked

Macro Coding for Forms in VBA

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I am working on a Form in VB for Applications.

I have to get the text entered into the text boxes on the form. To be entered in one click of the relevant command button to numerous points through out my document.

I am unsure of the coding for this and was hoping some one may be able to help me out.

5 replies

by john_wills

Suppose your input boxes are text1 thru text5. Clicking the button invokes this code:
if isnull(text1) or... isnull(text5) _
then
msgox "you must put something in each of text1 thru text5"
else
ans1=text1 + text4/text3
ans2=text2-text5
endif

by timfox

Sorry Amanda, I'm not sure if what you are trying to achieve is clear. From your description, it appears as though you have one form and a report (document). The report should contain the values that are entered in the form's text boxes, as well as various other text that goes on your report.
To do this, the data that the user enters will need to be stored somewhere (in a table (easier)or text file (harder) - Are you actually using MS Access?).
If table- then the report includes the relevant table fields where the data is being stored.
If text file- then you will have to open and read the text file to use the values...

Answer1 (above) helps you to validate that the user has entered text in each text box, but to provide more than this, we might need more info from you to clarify your problem.

by timfox

I understand that you were trying to achieve this in Word. Did you try using the Mail Merge facility? It can be a reasonable approach depending on requirements...

This discussion is closed to new replies.