473,394 Members | 1,658 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,394 software developers and data experts.

help on subform and textbox

I am having some trouble with a subform.

I have a form that contains a subform about problem tracking. The subform contains the history of the problem as well as when the ticket was created for the problem.

recently, i added a textbox to the from which simply grabs the user that opened the ticket.

the button to create a new ticket contains code that automatically grabs the username of the computer and writes it to the subform with the following information:
user_name | date | "Ticket Created"

so now whenever a user clicks the new ticket button, it populates the subform as well as the new textbox.

as for the old problem tickets that do not show the user who created the ticket, is there any way to take the first username (first cell from first row) from the subform and copy it over to the textbox?

i hope i explained my problem clearly.

thanks!
Jul 15 '11 #1
8 2233
NeoPa
32,556 Expert Mod 16PB
Jeffrey:
i hope i explained my problem clearly.
I'm afraid most of what you say contradicts the rest of it, so it could be clearer. Let me see if I can take a stab at guessing what you meant to say though. You tell me if I'm anywhere near the mark.

You had a database which included a form and a subform connected by (Some problem identification). Previously, the subform contained controls to reflect both the date and the Ticket Information. This latter control possibly contains free-text describing some update or other to the situation pertaining to the problem. At this point there is no User_Name info maintained. At this point also the Command Button to create a new ticket sets values for the date as well as the Ticket Information only.

Then a new control was added to the subform called [User_Name]. The Command Button was updated to add this new information automatically by grabbing it from the computer.

All well and good, but the pre-existing records, those created before this latest change, have no values for this new control. You want to know how best to remedy this situation, and suggest that duplicating the first row might make sense.

Please let us know if that is an accurate reflection of your question.
Jul 15 '11 #2
Hi NeoPa,

your interpretation of my problem is close, but not exactly. you mentioned it's the new field i added for the subform, but it's actually, the new field i added for the main form. the username in subform is already there. i would like to copy the PREVIOUS usernames in the subform (located in row one and cell one) and put them individually into the new textfield on the main form.


------

Let me rephrase my problem.

I have a form that is connected to table 'primary'
i have a subform in that form that is connected to the table 'secondary'

recently, i added a new field in 'primary' that is called opened_by (text field)

i put that field onto my form and when the user clicks on 'new ticket' it puts their username into that field.

Now this only happens when the user clicks 'new ticket'. The usernames for the previous tickets created are not in the table since this new field was added recently.

In the subform, the field list contains the following:
1. username (query from a username table)
2. date
3. notes

Whenever the main form is opened and the user clicks 'new ticket', the username is populated into the username field of the subform.
so for example
1) i click 'new ticket'
2) username for subform is automatically added (subform)
username is also added to opened_by textfield (primary form)
3) today's date is added
4) the words "Ticket Created" is automatically added

Now what I want to do is the following
1) take the username from PREVIOUS tickets (which would be from the first row and the first cell of the SUBFORM)
2) copy that and put it into the username textbox in the main form (The one recently created)
Jul 15 '11 #3
Rabbit
12,516 Expert Mod 8TB
Use a subquery to select the top 1 username ordering by the date and then use that to update the primary table.
Jul 15 '11 #4
@Rabbit:

Can you give me an example sql statement?

Thanks.
Jul 15 '11 #5
Rabbit
12,516 Expert Mod 8TB
Expand|Select|Wrap|Line Numbers
  1. UPDATE someTable
  2. SET someField = (
  3.    SELECT TOP 1 someField
  4.    FROM otherTable
  5.    WHERE someTable.ID = otherTable.ID
  6.    ORDER by otherField
  7.    )
Jul 15 '11 #6
hmm..somehow i'm getting an error:

Expand|Select|Wrap|Line Numbers
  1. UPDATE user_problem_log 
  2. SET opened_by = ( 
  3.    SELECT TOP 1 user 
  4.    FROM usr_problem_list 
  5.    WHERE usr_problem_list.trouble_no = user_problem_log.trouble_no 
  6.    ORDER by date
  7.    ) 
  8.  
error: operation must be an updatable query.

and also, in my usr_problem_list table (the one that links to subform), there may be rows that have the same trouble # (meaning that in the subform, 3 rows were all related to that trouble_no)

this won't be a problem right?

or do i have to use some kind of SELECT DISTINCT TOP 1 if there is such thing.
Jul 15 '11 #7
Rabbit
12,516 Expert Mod 8TB
Looks like you won't be able to use a subquery in the update, try a join instead.
Jul 16 '11 #8
NeoPa
32,556 Expert Mod 16PB
So, it seems you want to reflect the username of the first Ticket (I believe you call this table [Usr_Problem_List]) on each problem record (I believe you call this table [User_Problem_Log]). This would be straightforward enough, except you have existing records where this data has not already been reflected. It's always been there for Tickets, but not for the Problems.

I would say there are two issues to deal with here :
  1. How to update the existing [User_Problem_Log] records to set [Opened_By] to reflect the [User] of the first matching record of [Usr_Problem_List].

    This is where Rabbit was assisting with his UPDATE SQL code. I suspect what is required is a JOIN between the two tables on matching records with a filter to exclude all such matching records that have other matching records from the [Usr_Problem_List] table with earlier dates. Without the fields to use in the JOIN though we can't do the SQL for you.

    It should be easy enough to do in the Query Design Grid though. See what you can come up with, and if you can't get it to work then post the SQL you're trying. That should at least indicate what it is we're supposed to be working with.
  2. How to ensure, on an ongoing basis, that only the first Usr_Problem_List.User value entered is ever used to update User_Problem_Log.Opened_By.

    NB. I will assume for now that updates to the first Usr_Problem_List.User need not be reflect in User_Problem_Log.Opened_By if/when changed.

    This is easier to handle. The code to update the control on your main form that's bound to User_Problem_Log.Opened_By (after Usr_Problem_List.User is entered) need only check that the current value is Null before updating. If the value is not Null then it's been done before and the new value is either not the first record to be added, or it is, but it's a later update.
Jul 18 '11 #9

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

Similar topics

3
by: pepino13 | last post by:
Hello, I have a a form called frmMissyFact, I have copied this form and called it frmMissyFactBackup which reads data from a backup database of the week before. I brought frmMissyFactBackup into...
2
by: Bob | last post by:
Hi Everybody I have a form and Datasheet Subform If I select the top of the column ie the title of any one of the columns, I can manually focus on that vertical column. My question; is...
2
by: Paul T. RONG | last post by:
Hello there, I have a main form frmOrder and inside a subform sbfrmOrderDetail. When I add records from main form to subform, it is alright when the records don't exceed 40 rows (the subform's...
3
by: | last post by:
Hi , I did ask before but got no replies. I have a series of textboxes, In Enter event I need to set the focus to a different textbox I am having problems when I set focus within the Textbox...
4
by: Jurjen de Groot | last post by:
I'm developing a ASP.NET/VB.NET web application. (VS.NET 2003) I've created several webpages, but on two pages one textbox colors yellow (the background) and I can't get the background to appear...
2
by: Christina | last post by:
Hello !! I am creating a dynamic textbox and want to validate it using the requiredfieldvalidator. These are the steps which I tried: ==================================================== 1)...
5
by: Don Do | last post by:
Ok, this is my 2nd ever post. 1st one was solved quickly. Thanks. Now I'm stuck again. My mdb has a main form with 3 subforms. Each tied to the succeeding by single autonumberID/foreign...
7
by: Scotter | last post by:
Ok, heres the problem I have a main form with a subform. I want to have a text field that displays a field from the table my subform is based on. I tried just putting it there, but then the sub...
13
by: BASSPU03 | last post by:
Hello, folks. This is my first post and I only began to work extensively with Access about 3 weeks ago. I'm running Access 2003 on Windows XP. I'd like a textbox in subform2 to reflect the value...
2
by: adigga1 | last post by:
Good Day Experts, I have an issue dealing with a subform operation whereby, each time I select the value field of the subform, that same value is then placed into the source table as a new...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...

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.