?
Solved

Use a second form to fill entries in the first form

Posted on 2014-09-10
6
Medium Priority
?
261 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
6 Comments
 
LVL 85

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 2000 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 48

Expert Comment

by:Dale Fye
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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 85
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 48

Expert Comment

by:Dale Fye
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

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
The Windows Phone Theme Colours is a tight, powerful, and well balanced palette. This tiny Access application makes it a snap to select and pick a value. And it doubles as an intro to implementing WithEvents, one of Access' hidden gems.
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…
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…

719 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