473,626 Members | 3,388 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Dynamically generate text in a form text box

2 New Member
Hi,

I'm somewhat familiar with access and vb programming (I can read someone else's code, for the most part), but I'm still very green when it comes to creating solutions for my own needs.

I'm trying to create a db for a friend's business. I have two issues that I'm wrestling with. First is how to dynamically create a text box on a form.

I'm building a form that relates information between two tables (A, B). Table B is the source of the majority of the data on the form, while table A includes customer contact info (the tables are linked in a relationship).

I'm using a combo box to select customer information from table A. The cbx includes LastName, FirstName MI. and DateofBirth (in that arrangement). Hidden values include the customer ID (primary key) and date when the customer was entered into the db.

I want to dynamically generate a boilerplate with the customer's address and phone number right below the cbx. The information will be specifically used for this form and the current user. Any subsequent review of the data will be generated in a report that will automatically populate from both tables (I haven't created this report yet, though, so I may be posting again :) ).

I'm assuming the solution will be a vb code based on some event (After Update?), and will define the caption property. Any help on this one?

Hopefully, the second problem is easier. There is a checkbox on Table A which must be set to True. The box defines whether or not an insurance liability form has been completed before specific sales are completed (paint ball markers JFYI). This information is best stored on Table A (customer info) than on Table B (sales info) because one customer may buy several markers over a period of time.

I want to display the status of the checkbox on the form. I also want the user to be able to update Table A by using this checkbox. I found a workaround for this problem on another form where I used the tag property of the cbx and I created another textbox and an "Update" button which could update Table A based on the information in the second text box (does that make sense?).

However, that was a textbox, not a checkbox, so I'm not sure if it will work the same. Assuming it will work, and since there is still only one item that I must be able to change in Table A from this form, should I just do the same thing? Or, is there a more direct and efficient way to accomplish this?

Thanks in advance for any help offered.
Mar 31 '08 #1
2 6520
Zwoker
66 New Member
Hi,

Looking only at your first question:

Having a quick Google for creating objects in VBA for MS Access I found some code that works, but it seems that it can't be used to update the form you are running from... So perhaps this doesn't help you.

Does anyone know how to do this on the current form you have the code running in?

An alternative may be to have the text boxes already created on your form, but have the Visible property set to No until you need to display them.

Anyway, here is the code for what it is worth. It is assumed that the code is called from a form other than the one that the code references (test_form). I tried this (in MS Access 2003) and it worked fine.

Expand|Select|Wrap|Line Numbers
  1. Private Sub MakeATextBox()
  2.   ' Creates a text box of the name "tbxTest" using the control source "txtTest"
  3.   ' The text box is 1 in wide, 2 inches high, placed 0.5 inches from the
  4.   ' top and left of the detail
  5.  
  6.   Const TWIPS As Integer = 1440 ' text box dimensions are in twips
  7.   Dim ctl As Control
  8.   Dim intLeft As Integer
  9.   Dim intTop As Integer
  10.   Dim intWidth As Integer
  11.   Dim intHeight As Integer
  12.   intLeft = 0.5 * TWIPS
  13.   intTop = 0.5 * TWIPS
  14.   intWidth = 1 * TWIPS
  15.   intHeight = 2 * TWIPS
  16.  
  17.   DoCmd.OpenForm "test_form", acDesign
  18.   Set ctl = CreateControl("test_form", acTextBox, acDetail, , "txtDesc1", intLeft, intTop, intWidth, intHeight)
  19.  
  20.   ctl.Name = "tbxTest"
  21.   DoCmd.Close acForm, "test_form", acSaveYes
  22. End Sub
  23.  
  24. ' Call the code from where ever it is needed.
  25. MakeATextBox
Mar 31 '08 #2
ssmith147
2 New Member
I see what the code is trying to do, and it makes sense. I'll have to play with it a little bit tomorrow. I'm thinking the command should be able to generate the box on the same form using the 'Me' call, but I'll find out.

Also, I was unclear about how I was going to run this. The information box will already be in place on the form, but the information presented in it will be left blank until a selection is made from the combo box. I will definately try settig the visible property, though, as this may work very simply.

My major concern is whether or not vb can dynamically create the text in the same form (which still seems to be in question) and if it can do so based on the primary key data of a foreign table.

Thanks for the code- its a good place for me to start. If anyone can gather more info on this or the second question, I would still appreciate more help.
Apr 1 '08 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

7
25353
by: Rathtap | last post by:
I want to write a C# application (lets call it Generator) that will receive an argument(patient account number) and dynamically generate a series of linked HTML files (claim information, payments, denials etc) by querying a database based on the argument. This Generator can be called from an aspx web page, a Cold Fusion page as well as from a windows application. 1. Does this C# app have to be a console application to receive arguments?...
0
3409
by: Avon | last post by:
Hi friends, I am very sorry for my not perfect English. I have one question, I am using David Bauer's DynamicControlsPlaceholder to dinamically generate controls and I am tryig to generate MultiViev, at first it working, when I click btn1 I set SetActiveView to viev1 and it's working OK, but when after that I click btn2 and try to set SetActiveView to 2, I receive this error:
9
1857
by: sashang | last post by:
Hi I'd like to use metaclasses to dynamically generate a class based on a parameter to the objects init function. For example: class MetaThing(type): def __init__(cls, name, bases, dict, extra_information): super(MetaThing, cls).__init__(name, bases, dict)
1
1745
by: firenet | last post by:
21 function js_reply_msg(node,g_id,u_id,par_id) 22 { 23 node.innerHTML="<FORM><TEXTAREA name=\"msg_con\"><\/TEXTAREA><br><INPUT type=\"submit\" value=\"reply\"><\/FORM>" 24 node.nextSibling.nextSibling.innerHTML="" 25 } My thought is that when i clicked a link,the js function generate the Form,then get the input and deal with it.
1
3442
by: Scott Zabolotzky | last post by:
I'm sure somebody has to have done this already but I can't find any good references. If I have an XML file with an associated XSD what is the best way to dynamically generate a web form with proper controls for the various elements in the XML file? I found an article that describes how to do it using stylesheets (http://www.dnzone.com/ShowDetail.asp?NewsId=151) but it's a little cumbersome and was tailored to .NET 1.1.
2
1438
by: Steven C | last post by:
Hello: I'm trying to dynamically generate some labels for a form, and I can't seem to get it to work. The code is as follows. The first label is generated, but subsequent labels are not. Is there a better technique for this for(int i=0; i <= intLabCount; i++) { strArrLabAccounts = "lblCaption" + Convert.ToString(i).Trim();
7
1356
by: kendu | last post by:
Is it possible to dynamically load a form from file? This form is just a .vb file and has not been added to the project during design time. Ken
4
2173
by: high | last post by:
hi, im new to this platform, i have been creating a web page using MS Front page and i need to insert a text area to give the input and another text area to store that, <form name="myform"> <div style="left: 456; top: 803; width: 707; height: 59; position: absolute"> <table border="0" cellspacing="0" cellpadding="5"><tr> <td><textarea name="inputtext" rows="1" cols="20"></textarea></td> <input type="radio" name="placement"...
10
2952
by: phopman | last post by:
Hi there! Thanks for all the help so far. When my boss said I should be up to date as soon as possible, he meant last week. So I got a good rollicking when I came to work. Nice way to start my day.... Back to my problem: I have a Text in Mysql: The code for fetching it in php is: $id = intval( mysql_real_escape_string( $_GET )); $query = "SELECT * FROM jos_issues WHERE jos_issues.contentid= '$id' ORDER BY text desc"; $result =...
0
8268
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8202
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8641
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8366
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7199
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5575
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4093
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4202
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2628
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.