Solved

Use a second form to fill entries in the first form

Posted on 2014-09-10
6
258 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 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
Technology Partners: 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 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

Ransomware-A Revenue Bonanza for Service Providers

Ransomware – malware that gets on your customers’ computers, encrypts their data, and extorts a hefty ransom for the decryption keys – is a surging new threat.  The purpose of this eBook is to educate the reader about ransomware attacks.

Question has a verified solution.

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

Suggested Solutions

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …

740 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