I have a program that needs credentials to be added to a log on form before the main form can be displayed. See code:
If loginSuccess = True Then
'Me.UseWaitCursor = true
If wincheck.Checked = True Then
loggedinUser.currentUser = Environment.UserDomainName & "\" & Environment.UserName
Else
loggedinUser.currentUser = usernametxt.Text
End If
Mainfrm.Show()
Me.Close()
'Me.UseWaitCursor = false
Else
MsgBox("Login failed. Please check your credentials.")
End If
The issue is, once the credentials are entered and the mainform begins to load in, there is no indication that the mainform is loading. I feel like a splash screen is unnecassery because it only takes around 5 seconds to load.
I either want the mouse icon to change to indicate something is loading, or I want a loading icon to be displayed over the login form.
Any ideas?
Related
In my Clients form I have 2 textboxes (tbHHName, and tbHHID) and a navigation control (nav) displaying subforms/subreports.
When the user clicks tbHHName, a modal form opens to select which client to view.
Before switching clients, the form shows:
tbHHName: Client123
nav: Account1, Account2, Account3
After switching to Client456, here's what it displays:
tbHHName: Client456
nav: Account1, Account2, Account3
Here's what it should be displaying:
tbHHName: Client456
nav: Account4, Account5, Account6
After the user clicks on one of the nav tabs it displays correctly, but I can't figure out how to force refresh the nav control without that click. Any advice would be very much appreciated.
All of the nav's subforms/subreports have the NavigationWhereClause set to: "[HH_ID] = tbHHID"
Below is the Form_Load, and the tbHHName_Click subs
Private Sub Form_Load()
On Error Resume Next
'Set form recordsource
Me.RecordSource = "SELECT * FROM _HOUSEHOLDS WHERE HH_ID = " & GetSetting(AppName, Reg_JBGeneral, Reg_HH_ID, 0)
'Apologize to users
MsgBox "Please click on the Holdings tab again to refresh the data." & vbNewLine & _
" Sorry for the extra click," & vbNewLine & _
" -MaybeOn8", , AppName
End Sub
Private Sub tbHHName_Click()
On Error Resume Next
'open the form that sets new HH_ID value using the SaveSetting method
DoCmd.OpenForm "Households_Select", WindowMode:=acDialog
Form_Load
End Sub
Thanks in advance, SO
I tested with UNBOUND combobox sitting on main form to select filter parameter and NavigationWhereClause has criteria expression HH_ID=Forms![NavForm]!Combo9. Code in combobox AfterUpdate event:
Forms![NavForm]!NavigationSubform.Requery
Then I tested with code to change value of combobox and requery.
Forms!NavForm.Combo9 = 17
Forms!NavForm.NavigationSubform.Requery
This all works and does not involve changing RecordSource. Now just decide where to place code that changes control's value and requery subform.
Also, can use DoCmd.BrowseTo method to set focus on particular Navigation tab.
Found a fix. I tacked this onto the end of the Form_Load sub:
Forms("Households").NavigationSubform.Report.FilterOn = False
Forms("Households").NavigationSubform.Report.FilterOn = True
Even though there are mixed subforms and subreports in the navigation control, everything seems to load fine.
I have the following code on a subform's on current, but it errors on open of the main form:
If IsNull([Forms]![frmMContacts]!ID) Then
With Forms!frmMContacts!frmMContacts_SubPeopleContacts.Form
.Enabled = False
End With
Else
With Forms!frmMContacts!frmMContacts_SubPeopleContacts.Form
.Enabled = True
End With
If Me.NewRecord Then
Me.txtCurrRec = "New Contact Role Record"
Else
Me.txtCurrRec = CStr(Me.CurrentRecord) & " of " & _
DCount("ID", "tblContactPeople", "FKClient = " & Me.Parent.CM_CID) & " Contact Roles"
End If
End If
The point of it is, simply to update a text box in the form's footer, to provide a count of records for the sub form. The issue is that when a user opens the main (parent) form, from the main menu, the main record has no record, and the sub form is still loading. In reality, I'm hiding the detail of the main form, and hence this sub form is hidden. The user has to hit 1 of 2 buttons in the main form header. Either find a record (pop-up form) or start a new one (another pop-up form).
When I try to open this main form, I get the error "run-time error '2465' application-defined or object-defined error".
I'm not sure how to trap this and just either make the sub-form disabled or prevent this on-current code form firing, until the parent has a record.
Thanks for any help!
I have an excel file with full command buttons, I want to disable some buttons with one click.
I'll appreciate your help.
Thanks
With the details you provided in your question, I would say that what you look for is:
By default, all the buttons are saved with ButtonX.Enabled = False (some of them might default with the Enabled = True property if they are meant to be available to all the users);
When the user inputs username and password in the form, you might want to run a code like this:
If userNameBox.Text = "Ahmad" And passwordBox.Text = "1234" Then
Button1.Enabled = True
Button3.Enabled = True
Button5.Enabled = True
'and so on with the buttons you want to activate
End If
Of course, this should be the code of the event-macro related to the submission of the Username/Password user form, let's say:
Private Sub StartUserFormButton_Click()
'code here
End Sub
I am a casual programmer with not a lot of experience. I am happy I have made it this far on my own (with help of course from this site and others like it). But now I need some help.
I have created a user control with several text boxes, masked text boxes, combo boxes, a check box and 3 buttons.
I have created a form (Form1) with a tab control (TabControl1) that has 1 tab page on it (TabPage1). I have added my user control to TabPage1 and the control assumes the name ContactTab1. This was done through the VB.net form design, not by code.
When I run my form I have code so that when I click on my add button, it adds another tab with my user control added to it (no matter which tab I may be on). It works great, I can add as many tabs as I want. When I click on my edit or delete button, they work great in the sense that I know which tab the button is on when it gets clicked. My problem is when I click the edit button I need to set ckbDeleteContact.Checked = False and ckbDeleteContact.Visible = False on the tab that the button was clicked. When I click the delete button I need to set ckbDeleteContact.Checked = True and ckbDeleteContact.Visible = True on the tab that the button was clicked. I can access the check box on the first tab without a problem with the statement ContactTab1.ckbDeleteContact.Checked = False.
So my question is, how do I access all these text boxes, masked text boxes, combo boxes, and my check box on these dynamically added controls? Below is my code for Form1 and I have commented out what I need working:
Public Class Form1
Private intTabPage As Integer = 1
Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
TabPage1.Text = "Contact #" & intTabPage
ContactTab1.ckbDeleteContact.Checked = False
ContactTab1.ckbDeleteContact.Visible = False
TabPage1.Name = "TabPage" & intTabPage
intTabPage = intTabPage + 1
End Sub
Private Sub UC_btnAddContact_Click() Handles ContactTab1.UC_btnAddContact_Click
AddNewTab()
End Sub
Private Sub UC_btnEditContact_Click() Handles ContactTab1.UC_btnEditContact_Click
'**DEBUG: See which tab the button is on when clicked
MessageBox.Show("The edit button from the following tab was clicked: " & TabControl1.SelectedTab.Name() & vbCrLf & "The edit button on the following contact tab was clicked: " & TabControl1.SelectedTab.Controls.Item(0).Name(), "Check", MessageBoxButtons.OK, MessageBoxIcon.Information)
'This code is what needs to work. ContactTabObject would have naming convention "ContactTabX" where X = the tab # 1 through the highest tab #
'ContactTabObject.ckbDeleteContact.Checked = False
'ContactTabObject.ckbDeleteContact.Visible = False
End Sub
Private Sub UC_btnDeleteContact_Click() Handles ContactTab1.UC_btnDeleteContact_Click
'**DEBUG: See which tab the button is on when clicked
MessageBox.Show("The delete button from the following tab was clicked: " & TabControl1.SelectedTab.Name() & vbCrLf & "The delete button on the following contact tab was clicked: " & TabControl1.SelectedTab.Controls.Item(0).Name(), "Check", MessageBoxButtons.OK, MessageBoxIcon.Information)
'This code is what needs to work. ContactTabObject would have naming convention "ContactTabX" where X = the tab # 1 through the highest tab #
'ContactTabObject.ckbDeleteContact.Visible = True
'ContactTabObject.ckbDeleteContact.Checked = True
End Sub
Function AddNewTab()
Dim NewTab As New TabPage
Dim NewContactTab As New ContactTab
TabControl1.Controls.Add(NewTab)
TabControl1.SelectTab(NewTab)
NewTab.Text = "Contact #" & intTabPage
NewTab.BackColor = System.Drawing.Color.Transparent
NewTab.Controls.Add(NewContactTab)
NewTab.Name = "TabPage" & intTabPage
NewContactTab.Location = New System.Drawing.Point(6, 6)
NewContactTab.BackColor = System.Drawing.Color.Transparent
NewContactTab.ckbDeleteContact.Checked = False
NewContactTab.ckbDeleteContact.Visible = False
AddHandler (NewContactTab.btnAddContact.Click), AddressOf UC_btnAddContact_Click
AddHandler (NewContactTab.btnEditContact.Click), AddressOf UC_btnEditContact_Click
AddHandler (NewContactTab.btnDeleteContact.Click), AddressOf UC_btnDeleteContact_Click
NewContactTab.Name = "ContactTab" & intTabPage
intTabPage = intTabPage + 1
End Function
End Class
Once I get this figured out, I should be good to go and I should be able to get the rest on my own. In case you are wondering, I will also be filling in the options for my combo boxes with data from a database. I will then be using the form to take all the data in it and either adding, editing, or deleting the information from a database.
Thanks in advance.
As #HansPassant said you just need to add properties to your user control to get access to your controls in it. I'm not a vb.net guy, but I think this is going to help you:
Public Function MyTextbox() As System.Windows.Forms.TextBox
Return Textbox1
End Function
You can write this in your user control code.
Ok, maybe I was not the clearest in my post or I just don't understand the encapsulation thing. I can access all my controls since they are standard controls. I just needed to know how I could get the name of the parent control, which in this case is the user defined control named ContactTabX where X = 1 through n controls that were added when I pressed my add button n times. I could always access them by saying something likeContactTab5.ckbDeleteContact.Visible = True or whatever. I did not want to hardcode since I would not be sure how many tabs were added so I wanted a way to know which tab I was on when the button was pressed that way I could change that check box property on that particular tab (since every tab is identical).
I spent hours trying to figure it out and well here is what I was able to figure out about 10 mins after posting the question (go figure). I hope this helps anyone else. And for you experts out there, any feedback is appreciated on my solution. I always like to learn :)
So replacing the subs I originally posted with these worked perfectly.
Private Sub UC_btnEditContact_Click() Handles ContactTab1.UC_btnEditContact_Click
'**DEBUG: See which tab the button is on when clicked
'MessageBox.Show("The edit button from the following tab was clicked: " & TabControl1.SelectedTab.Name() & vbCrLf & "The edit button on the following contact tab was clicked: " & TabControl1.SelectedTab.Controls.Item(0).Name(), "Check", MessageBoxButtons.OK, MessageBoxIcon.Information)
Dim Contact As ContactTab = TabControl1.SelectedTab.Controls.Item(0)
Contact.Name = TabControl1.SelectedTab.Controls.Item(0).Name()
Contact.ckbDeleteContact.Visible = False
Contact.ckbDeleteContact.Checked = False
Contact = Nothing
End Sub
Private Sub UC_btnDeleteContact_Click() Handles ContactTab1.UC_btnDeleteContact_Click
'**DEBUG: See which tab the button is on when clicked
' MessageBox.Show("The delete button from the following tab was clicked: " & TabControl1.SelectedTab.Name() & vbCrLf & "The delete button on the following contact tab was clicked: " & TabControl1.SelectedTab.Controls.Item(0).Name(), "Check", MessageBoxButtons.OK, MessageBoxIcon.Information)
Dim Contact As ContactTab = TabControl1.SelectedTab.Controls.Item(0)
Contact.Name = TabControl1.SelectedTab.Controls.Item(0).Name()
Contact.ckbDeleteContact.Visible = True
Contact.ckbDeleteContact.Checked = True
Contact = Nothing
End Sub
Thanks again for the input.
Hoping someone can help me with this. I have two separate but related Forms, one of which contains a WebBrowser control. The user fills out some information on Form 1 and clicks a button with the following code:
If Form2Shown = False Then
Dim memoscreen As New Form2
Form2Ref = memoscreen
memoscreen.show()
Form2Shown = True
memoscreen.TopMost = OptionOnTop
Else
Dim memoscreen As Form2
memoscreen = Form2Ref
memoscreen.TopMost = OptionOnTop
memoscreen.QuickRefresh()
End If
The QuickRefresh sub in Form2 is the method that navigates. It is called both when the form is loaded as well as manually in the code above:
Public Sub QuickRefresh()
Dim HM As Form1
HM = Form1Ref
Me.Text = "retrieving information..."
Me.AxWebBrowser1.Navigate("SomeValidURL")
HM.Focus()
HM.SetHugoFocus()
End Sub
The problem I'm having is that the first time QuickRefresh is called (i.e. when Form2 is loaded) the navigation is successful and the page displays fine. If I then click the button on Form1 again, the page does not change. The Text attribute and window focus does change however, so I know the method is firing.
Some things I've tried/checked:
AllowNavigation is set to True on the WebBrowser control
Have tried looping while the browser is busy while calling Application.DoEvents()
Any suggestions would be appreciated. Thanks.
From your "Internet Options dialog > General Tab > Settings Button > Check for newer version of stored page" change that option to *Every Time I visit the webpage". That setting impacts how the webbrowser control deals with the refreshing.
Use the method refresh.
browser.Navigate("http://www.google.com") : browser.Refresh()