Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 265
  • Last Modified:

Use a second form to fill entries in the first form

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
TIgerV
Asked:
TIgerV
  • 2
  • 2
  • 2
1 Solution
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
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
 
Dale FyeCommented:
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
 
TIgerVAuthor Commented:
Thank You!

Dale- I am sure, as usual, your solution was excellent, but I'm just not VB Savvy enough.
0
Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

 
TIgerVAuthor Commented:
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
 
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
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
 
Dale FyeCommented:
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

  • 2
  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now