MS - Access automatic scroll on list box. - ms-access

I have created an access database form that displays a list of users and their productivity within a listbox. However when I get above 20 users, the list box cannot display the rest without scrolling.
Is there a way that I can make the listbox scroll automatically to the bottom and then reset to the top like the end credits in a movie played on an endless loop?

To do what you appear to be asking I think you need to build your own scroller!
I would use these things to achieve that:
a text box set to multi-line
an array with each line of text to display in separate cells (or a recordset if you are brave)
a timer function to update the text box
a global counter to track the current first-line number of the text being displayed
Pseudocode:
Init:
clear the text box
load the array with the text & append each line to the text box as you go.
set the pointer to 1
UpdateText (timer event):
' get length of current string
iLength = array(counter).text.length
' chop the first row off the text
textbox.text = right(textbox.text, len(textbox.text) - iLength)
' add the text back on to the end
textbox.text.appendtext( array(counter).text)
increment counter
if counter > array-num-items, set counter to 1 ' scroll over
have fun!

Related

how to create a combo box in access which can be converted to text box to enable writing if the user needs to add a new option to the existings?

I was wondering how I can define a combo box in a form where the user can select an option from the existing list, and if he can't find the desired option, a "add a new option" can be accessed which converts the combo box to a text box for writing the new option?
You can put a button next to the combo, for an 'add option' which is triggered when the combo 'not in list' event is hit - and the button then would call a popup form - or in your suggestion, changes the visibility of an overlayed text box that allows for entry. I suggest a popup form, however, because then you can validate the input for length, content, etc - and then once the form or text box is filled in - exiting the text box, or submitting the form would save to your table for the drop down, refresh the combo box source query, and assign the value. I do this in VBA alot with popups.
Sorry my bad english :-(
You can directly use the "On Not in List" event. Look at the examples at
https://learn.microsoft.com/en-us/office/vba/api/Access.ComboBox.NotInList
This is the scenario: A combobox called cb and a textbox called tb. Visible property of tb is false. Combobox and Textbox have the same data source. When you type a value that is not in the combobox list, that value goes to the textbox; when you finished editing textbox, it is hidden again.
Private Sub cb_NotInList(NewData As String, Response As Integer)
' Suppress error message and undo changes.
Response = acDataErrContinue
Me!cb.Undo
' Prompt user to verify they wish to add new value.
If MsgBox("Value is not in list. Add it?", vbOKCancel) = vbOK Then
Me!tb.Visible = True
Me!tb.Value = NewData
Me!tb.SetFocus
End If
End Sub
Private Sub tb_AfterUpdate()
' Hide again texbox
Me!tb.Visible = False
' Update combobox items
Me!cb.Requery
End Sub

Update result of formula in text box

I'm trying to update an unbound text box in a form I'm building.
The text box has a default value which is: =DLookUp("[Metadata]![Username]";"[Metadata]").
When the value in the field username is changed;
how do I update this change in the text box without closing the whole form and then opening it again?
--
I've tried to to do this by adding a button in the form and then on mouse up event try and either by vba or the macro editor find a solution.
It would supposedly be possible to create a macro that will close and then open the form again but it's not really what I'm looking for.
VBA: I found lots of suggestions for requery but I couldn't get this to work:
Set UserName = Forms![Update test]!Text10
UserName.Requery
A general solution that could work with multiple such text boxes is preferable
(but not required, anything that tries to point me in the right direction is welcome).
Go to the design view and select the textbox which represents your table value username, then go to events and select the On Change() event:
Private Sub username_Change()
YourTextbox.Value =DLookUp("[Metadata]![Username]";"[Metadata]")
End Sub

Access VBA Create Word header with text and position picture

Having trouble getting access vba to set a word document's header properly. I've got this.
oDoc.PageSetup.DifferentFirstPageHeaderFooter = True
oDoc.Sections(1).Headers(wdHeaderFooterFirstPage).Range.InlineShapes.AddPicture "C:\Users\mr.helpless\Pictures\doody.jpg"
oDoc.Sections(1).Headers(wdHeaderFooterFirstPage).Range.Text = "hello there"
oDoc.Sections(1).Headers(wdHeaderFooterPrimary).Range.Text = "whooo hooo!"
What happens right now is the text will replace the picture for the first page (subsequent pages are fine).
I need to have the picture and text - and I need to offset the picture to the left about half an inch while text is centered with normal margins.
Any idea how to go about it? Basically I need to set a document letterhead with a logo.
Update
Dim myText As String
myText = "hello there"
With oDoc.Sections(1).Headers(wdHeaderFooterFirstPage)
.Shapes.AddPicture Filename:="C:\Users\mr.helpless\Pictures\doody.jpg", LinkToFile:=False, SaveWithDocument:=True
.Range.Collapse
.Range.InsertAfter (myText)
.Range.Font.Name = "Helvetica"
.Range.Font.Size = 8
.Range.Font.Bold = True
.Range.Paragraphs.Alignment = wdAlignParagraphCenter
End With
I've got half of it done, now I just need to position the image to -.5 to margin.
Completed Solution
Just add "Left:=-35" to the picture like such (or whatever value works)
.Shapes.AddPicture Filename:="C:\Users\mr.helpless\Pictures\doody.jpg", LinkToFile:=False, SaveWithDocument:=True, Left:=-35
Have you tried recording a macro in Word that does the rough reposition - then bring the code over to Access and edit it for the correct object and size?
All of it is updated in the original thread. it took using the .Range Collapse to add in text along with the image and it took putting Left:=(value) to move it where I needed it.

How to create a new text field via a button in as3?

I've been having this problem forever now. All I want to do is create a button that adds a new (input) text field that is located right beneath the previous one (Like perhaps, a user creating a bullet list with a certain amount of items).
Here is the code I have so far (that pertains to the topic)
function addCompanySlotButton(b:MouseEvent){
for(var i:Number = 0;i<slotArray.length;i++){ //slotArray holds the number of text fields (slots) that exist.
company_slot.name = "slot"+(i); //This is supposed to name the newly-created text field by its index number. (company_slot is just a variable name for the text fields)
company_slot.y = 30*slotArray.length; //This is supposed to move the newly-created index slot down by 30 * (whatever it's index number is).
company_slot.x = 75;
company_container.addChild(company_slot); //company_container is just a display object that shows the text fields/company slots.
}
slotArray.push(company_slot);
trace(slotArray.length); //This number increases every time the button is pressed, so I know for sure that there is more than one text field.
}
However, it appears as though all of the text fields are in the same spot, and whenever the button is pressed, ALL of them move instead of just one. I'm pretty new to actionscript (and coding in general), so any help is greatly appreciated.

Auto insert area code

I have a text box in Microsoft Access 2013 that corresponds to a telephone number. The text box has the input mask of:
!\(999") "000\-0000;;_
I am trying to auto insert the area code. For example, when a users goes to enter a telephone number, the area code is already populated into the text box. I have tried to set the default value in both the table design and on the property sheet of the text box but no luck. Its always aligned to the right. For example it looks like this:
If I add spaces to the default value on the text box property, the input mask is ignored and Microsoft Access generates an error stating:
The value you entered isn't appropriate for the input mask '!(999") "000-0000;;_' specified for this field.
I have contemplated modifying the table structure to include a specific field for an area code, but that is my last resort.
Is there a more efficient way to automatically populate the area code in the text box when a new record is generated?
You can write a function in VBA to do this. Something like;
Function FormatPhone(PhoneNumber As String) As String
FormatPhone = "(719)" & PhoneNumber
End Function
This function will take a string like '123-4567' and return '(719)123-4567'.
In the AfterUpdate event of your phone number field put;
[TextBoxControlName].Value = FormatPhone(Nz([TextBoxControlName].Value,""))
and this will add the formatted string to the text box.