Solved

Use a second form to fill entries in the first form

Posted on 2014-09-10
6
253 Views
Last Modified: 2014-09-11
I have an events log that my employees use daily to record what gets done.
I would like to have a button bring up a second form, that gives options for 'canned' entries.  Examples of a Canned entry would be: "Closed for Lunch" or "Primary Staff meeting".
Currently, I have a database that offers these buttons at the bottom, but they take up an excessive amount of room and I want to instead call them up by using a button.
My issues are 2 fold:
1.  On my current database (I'm scrapping it and starting over), the buttons are labeled automatically by a value in the table containing the entries.  Table includes these fields:  [ID], [Entry text], [short text].  For some reason, this code isn't working:
Private Sub FillOptions()
Const NUMBUTTONS = 16
 Dim seldata As String
 Dim num As Integer
 Dim dbs As Database
 Dim label As Recordset
 Set dbs = CurrentDb()
 seldata = "SELECT * FROM [tbl_Canned Entries]order by [ID];"
 Set label = dbs.OpenRecordset(seldata)
 While (Not (label.EOF))
   Me("toggle" & label![ID]).Caption = label![Short Text]
   label.MoveNext
   Wend
   label.Close
   dbs.Close
   
End Sub

Open in new window


The second piece is what is the easiest way to get the text from the table to post?   a button that says "USE THIS"?
0
Comment
Question by:TIgerV
  • 2
  • 2
  • 2
6 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 40315459
You could create a form that shows your "default" entries, perhaps in a Listbox. In the DoubleClick event of that listbox, you could run code like this:

Forms("YourMainForm").YourField = Me.YourListBox.Column(0)

Note that Column(0) refers to the FIRST column in your listbox, if it has more than one, so be sure to set that value accordingly.
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 40315589
or you could create a shortcut menu and use that.

Here are a couple of articles I wrote about using shortcut menus:
Understanding and using CommandBars (ShortCut menus), Part 1
Understanding and using CommandBars, Part II (Creating your own)
0
 

Author Closing Comment

by:TIgerV
ID: 40317763
Thank You!

Dale- I am sure, as usual, your solution was excellent, but I'm just not VB Savvy enough.
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 

Author Comment

by:TIgerV
ID: 40318016
This is working fine, however-
   I have moved the source form into a subform.  
I have:
Forms("frm_log entries").entry = Me.Litsbox4.Column(2)

However now "Frm_log entries" is a subform in "Frm_log page".   How do I direct the update to the subform?
0
 
LVL 84
ID: 40318156
To refer to a subform, you refer first to the Subform CONTROL, then the Form object, then the property/method:

Forms("frm_Log entries").SubFormCONTROL.Form.Entry = Me.Litsbox4.column(2)

SubFormCONTROL is the Subform Control that's on the main form. It may or my not be named the same as the form you're using as a Subform.
0
 
LVL 47

Expert Comment

by:Dale Fye (Access MVP)
ID: 40318393
Assuming that the subform control NAME is also "frm_log entries", the syntax would look like:

Forms("Frm_log page").[frm_log entries].Form.Entry = me.listbox4.column(2)

But it might be easier than that, depending on where listbox4 is located.  If listbox4 is located on "frm_log page" then the syntax would simply be:

me.[frm_log entries].form.Entry = me.listbox4.column(2)

Also, I would strongly recommend that you:
1.  stop putting spaces in your form or control names.  SPACES and special characters are bad!!!
2.  adopt a naming convention for all of your database objects and the controls on them.  this takes a little longer to actually go through your forms and reports and rename all of your controls so that the NAME property of all of the controls indicates the type of control (lbl_Date, txt_Date, cbo_Date, lst_Something).  This accomplishes two things.
    a.  it makes it easier to read your code and determine what control you are referring to (what is listbox4 off the top of your head?).
    b.  it distinquishes your controls from the fields on the form.  Yes, you can name your FirstName text box FirstName (Access actually does this for you).  But when you see me.FirstName in your code are your referring to the control, or to the value of the underlying field?  Better to have a control named txt_FirstName.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now