Ask Your Question
0

How are Base subforms named in LO basic? [closed]

asked 2016-03-25 19:51:40 +0100

docbda gravatar image

I am trying to edit a small macro that was kindly written for me by ratslinger in response to an inquirey I made regarding putting macro text in a Base form textbox. Since I have no way to contact him directly, I'm relegated to asking my question in the forums.

I'm a total noob at LO basic, so try not to laugh too hard. The macro is embedded in a Base form named "Patient Data". I need the macro to access a sub form named "Chief Complaint" instead of the main form "Patient Data". The code I'm trying to edit follows:

REM BASIC Sub ShowText(answer)

Dim oForm As Object
Dim oField As Object

oForm = ThisComponent.Drawpage.Forms.getByName("Patient Data") 

oField = oForm.getByName("test") 

oField.text = oField.text & Chr(13)  + Answer

End Sub

How do I pass the subform's name to the getByName function to access the subform instead of the main form? I've not been able to find the naming convention for subforms in LO via Googling.

Thanks, and I hope ratslinger doesn't mind me posting his code.

docbda

edit retag flag offensive reopen merge delete

Closed for the following reason the question is answered, right answer was accepted by Ratslinger
close date 2016-03-26 18:49:27.293263

1 Answer

Sort by » oldest newest most voted
1

answered 2016-03-25 20:22:38 +0100

Ratslinger gravatar image

Since you already have the form "Patient Data" use

oSubForm = oForm.getByName("Chief Complaint")

just as you would to get other controls. Use oSubForm to get at controls on the sub form.

BTW - any code placed here is not proprietary. It's available to anyone.

edit flag offensive delete link more

Comments

I got it to work! I think I'm done pestering you for a while. Thank you for your patience and kind assistance. :D I didn't think you would mind me posting a small snippet of your code. I just didn't know what the proper etiquette was in that regard. Best, docbda

docbda gravatar imagedocbda ( 2016-03-25 20:40:54 +0100 )edit

I have one final twist that I need to address. There are multiple text boxes in the form that I am designing. I need the text generated by the macro to be inserted into the text box that has focus at the time the macro is called. I've tried using "oField = oSubForm.getCurrentController()" instead of "oField = oSubForm.getByName("test")", which was the closest thing I could find find to a solution after a couple hours of research with no luck.

docbda gravatar imagedocbda ( 2016-03-26 01:11:42 +0100 )edit

Is there a function that will return the identity of the textbox that holds focus so that the name of the textbox can be assigned to a variable?

docbda gravatar imagedocbda ( 2016-03-26 01:14:10 +0100 )edit

Please understand, this is off topic and should be asked in a new question. Also, provide as much information as possible such as what is triggering the macro, the textbox or something else. If something else, how does the textbox have focus?

Ratslinger gravatar imageRatslinger ( 2016-03-26 01:53:43 +0100 )edit

Whoops, sorry about that. Kinda new to the whole forum thing. I did ask this as a new question in addition to this comment, however. I won't do that again in the future. I'll also ammend my question to address the issues you have brought to my attention. Thanks for the heads up.

docbda gravatar imagedocbda ( 2016-03-26 02:50:37 +0100 )edit

Question Tools

1 follower

Stats

Asked: 2016-03-25 19:51:40 +0100

Seen: 372 times

Last updated: Mar 25 '16