MS Access 2007: Programatically add hyperlink to a form with VBA - forms

A form populates and the OnLoad event tests for the value in a field. If that value is blank, then I want a hyperlink to appear in place of the textbox which I have figured out. The hyperlink needs to link to another form within the database which is my question.
Take the following snippit:
If cp = "" Then
Forms[!MyForm]![MyTextControl] = "Update"
Forms[!MyForm]![MyTextControl].IsHyperlink = True
' what is the code to add the link to the other form
Else
Forms[!MyForm]![MyTextControl] = cp
End If
Any thoughts on how to create a hyperlink that links to another form?

The text for a hyperlink in a textbox is:
="Form##form table1_form#This will open a form#"
="Display text#Address if required#sub address, eg form or report#screen tip#"

Related

selecting records on a continuous form, sending to a single form- access 2016

I have a continuous form to which I added a checkbox column for each record. I'd like to click on the checkbox and open a single view form for that specific system_id. This is my current code, it's prompting me for an ID field but when I enter the system_id field nothing happens. I don't want a prompt but rather have it seamlessly open the record into the single form. Continuous form is called: [P2P cases] and the single form is called: [P2P View]. Advice please!
current (not working) code:
Private Sub View_Click()
Forms("cases").Form.[P2P View].Form.Filter = "qaID=" & Me.system_id.Value
Forms("cases").Form.[P2P View].Form.FilterOn = True
Forms("cases").Form.[P2P View].Visible = True
If Me.system_id.Value = True Then
Forms("cases").Form.[P2P View].Form.system_id.SetFocus
End If
End Sub

MS Access: Enter a specific text in a form using command button from another form

I would like to ask for your help on the following issue in MS Access.
I had created a form "CustomerListF", filled with command buttons for each client. For each button, I had created the following code:
Private Sub cmd_outlets_ABC_Click()
DoCmd.OpenForm "OrderFormF"
Forms!OrderFormF!Outlets = "ABC"
End Sub
The button would then open another form "OrderFormF" and enter "ABC" in the textbox named "Outlets". However, I realized the second line of code (Forms!OrderFormF!Outlets = "ABC") would always create a phantom record in my subform, which is located in "OrderFormF", and this record would travel to other clients' forms. This phantom record is usually created when the commandbutton is clicked twice (double clicks or subsequent clicks). It is a headache when the record starts to shift around.
enter image description here
I would like to seek your advice for vba code to edit the second line of code.
Thank you.
This approach for filling the field in opened form is not good. OrderFormF initialization and second line of your code with assigning value to the field may be executed in different sequence, they are not synchronized.
In order to avoid this, you should pass the argument to OrderFormF by another way. I would recommend to use OpenArgs parameter:
DoCmd.OpenForm "OrderFormF",,,,,,"ABC"
And then in Load event of OrderFormF assign the value to textbox:
Me.Outlets = Me.OpenArgs
In this case the "ABC" value will be assigned to first row in the form or to new record, if form is empty. Before assigning you can select the row if you need to assign value not to the first row. Also this way will protect you against double click on button, Load event executed only once during first form opening

Hyperlink button to open a file

I have a Table (Table1) with a list of PDF files, and its Form (Form Table1).
In "Table1" I have a hyperlink field (PDF) and I want a button in "Form Table1" to open that hyperlink. I tried to select this button, go to Event>On Click>Code Builder and type
Private Sub Command1_Click()
Application.FollowHyperlink PDF, , True
End Sub
What is the correct method I should be using to achieve this?
An easy way would be referencing the pdf file's location by referring to the HyperlinkAddress using some VBA. Put this code on a button or whatever event you please:
Private Function Get_Link()
Me![mybutton].HyperlinkAddress = _
Nz(DLookup("[filename]", "[my_files_table]","[my_files_table].[id]=" & Me![id]), "")
End Function
To update the hyperlink you can refer to the Hyperlink's ID or primary key in a form by firing an event like: OnCurrent: Get_Link()
This would retrieve the current ID on your form and use that to get the hyperlink you want.
Reference: Bytes.com

in access need to doubleclick on record in subform to show detail on main form

I have a main form with a subform. The subform is continuous and shows all of the records. The main form works great for adding and editing records. I need to be able to double click on a record in the subform and that record be displayed on the main form for editing.
By experience I reccomend you to achieve what you are trying by placing two subforms into the master one. In one you have the list and in the other the details.
In the master form you place a hidden link field that is populated when you doubleclik on the list.
This field, let´s call it [link] is the Link Master Field in the detail subform, and the Link Child Field is the id (primary key) to identify your selection.
This will link your double click (or simple) with showing the details.
I found a solution that works to move to display the record from the subform in the master for editing.
In the DblClick event on the subform I put in the following code:
Let Forms!FrmNotes.CboNotesID = TxtNotesID 'TxtNotesID is the ID on the subform
Call Me.Parent.DisplayRecord
On the main for I created
Public Sub DisplayRecord()
CboNotesID.SetFocus
DoCmd.SearchForRecord , "", acFirst, "[NotesID] = " & "'" & Screen.ActiveControl & "'"
End Sub

Submit Form with nameless input in HtmlUnit

Good morning!
I need to post a form, I've already changed all the values inside that form (drop-drown list, text fields , check-boxes, etc), in this way:
final HtmlPage page4 = webClient.getPage("somepagemakinmemad");
HtmlForm formx= page4.getFormByName("lista_grupos");
changing values like:
HtmlSelect duracion = (HtmlSelect) page4.getElementByName("p_duracion_"+datum.getCrn()+"_1");
HtmlOption option1 = duracion.getOptionByValue("0029_029");
duracion.setSelectedAttribute(option1, true);
That is, I am changing the values through obtaining the html element from the page, not through the form (is that okay anyway?).
And then I try to submit the form, through:
<input id="p_guardar" class="boton" type="button" onclick="validaAPG()" value="Guardar">
Which is the "button-like" input where someone clicks when is over with the form.
I have to say, when I print the html code of the form, with "asXml()", I see the form the with selected values I've intended to select.
Question: How can I click on that button and send the form? That input runs a script, when clicked
Thanks everyone, let me know if you need any other kind of info.
You can use below code to click on the button to submit the form.
HtmlButtonInput button = (HtmlButtonInput)page.getElementById("p_guardar");
page = button.click();
You dnt need to care what script runs when clicked.If you dont need to run the script remove the attribute.