473,407 Members | 2,312 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,407 software developers and data experts.

Passed text doesn't appear until cursor is in Textbox

AccessQuestion
So all I am doing is passing data from one from into another.

Expand|Select|Wrap|Line Numbers
  1.     DoCmd.OpenForm "Task Details", acNormal, , , acFormAdd
  2.     Forms![Task Details]![Title] = "Work Order"
  3.     Forms![Task Details]![Start Date] = Now()
  4.     Forms![Task Details]![Employee] = Me.AssignedTech
  5.     Forms![Task Details]![Assignment] = Me.Description
  6.     Forms![Task Details]![cmdClose].SetFocus
  7.  
  8.  
Everything works except the Assignment to Description box. When the "Task Details" form opens, all the passed data is there, however the Description box is empty. But if you click within the box the passed Forms![Task Details]![Assignment] text appears. Why is it doing that?? Any help is greatly appreciated.
Jun 17 '10 #1
9 4106
MMcCarthy
14,534 Expert Mod 8TB
The Honest answer? I don't know :)

Let's try a few things.

Open the "Task Details" form in design view. Delete the assignment control then drag it back on to the form from the field list (I'm assuming the controls on this form are bound).

If that doesn't make a difference. Check the data source for both forms and see if the data type is text or memo on both, as in they have the same data type. Also check if the data type is text that the are set to the same number of characters.

Let me know if either of these things makes any difference.

Mary
Jun 17 '10 #2
NeoPa
32,556 Expert Mod 16PB
You say "The description box is empty", yet your code assigns the value currently in Me.Description to a control named [Assignment]. Is this the control you're referring to?

What type of control is [Assignment]?
Jun 18 '10 #3
So I replaced the control for Assignment - no change. Both controls are set to 'Memo'.

NeoPa - I sort of misspoke. The 'Me.Description' is coming from a form named 'Work Orders Status'. I am passing that data to a form named 'Task Detials' where it is reviewed and then placed into the table 'Tasks'Both controls are Text Boxes.

I cannot figure this one out for the life of me.

I suppose I could just submit from Work Orders Status directly into the Tasks table and eliminate the passing of data. I am just not clear on how to insert data into a table with VBA. I know it's 'Insert Into' but my first couple attempts failed. I admittedly gave up. I can give it another go, though.
Jun 21 '10 #4
Jerry Maiapu
259 100+
@AccessQuestion
Hi, if you are not clear on how to insert data from a FORM into a TABLE using VBA, then maybe I can help. Do post your question of what you trying to achieve. An unbound FORM with names of a couple of unbound text boxes and the destination table name and corresponding column names would do...

Now, for your question try and delete this line
Expand|Select|Wrap|Line Numbers
  1. Forms![Task Details]![Assignment] = Me.Description
then on the control source of the Assignment txtbox put this;
Expand|Select|Wrap|Line Numbers
  1. =Forms![Work Orders Status]![Description]
If it does not work I am just suspecting that one of the object name Description or Assignment is misspelled please check these two names again and verify.


Regards
Jun 21 '10 #5
Here is a quick video I took to show the issue.

http://www.youtube.com/watch?v=VSGBDQqp4FY

Jerry - I don't think I can change that to =Forms![Work Orders Status]![Description] simply because not only do I pass info to that form, I also enter directly to that form. Does that make sense? Maybe I can do it. Let me try and see if it errors out.

Also, I want to take the data from the 'Work Orders Query' form (the top form) and just place it directly into the Tasks table. Does that help you with helping me with the VBA? :) If a forms control does not have the same name as a field in the table what do you do with the Insert Into?

Thanks for all your help; I truly appreciate it.
Jun 22 '10 #6
By the way, here is the SQL statement I am trying to use to insert from this form into the Tasks table.

Expand|Select|Wrap|Line Numbers
  1.  DoCmd.RunSQL "INSERT INTO Tasks ([Title], [Status], [Start Date], [Employee], [Assignment], [WOID]) VALUES ( 'Work Order', 'Assigned',  Now(), '" & Me.AssignedTech & "',  '" & Me.Description & "', '" & Me.WOID & "');"
This is not working obviously and I have googled by #$@ off. Thanks for any help.

Also, once this is working, how do I prevent that box that Access throws up that says 'You are about to append one record....'

Thanks again.
Jun 22 '10 #7
Update: Solved. Not the best thing to do I guess, but I just refreshed the form once the data was passed.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command26_Click()
  2.     Me.Status = "Assigned"
  3.     DoCmd.Save
  4.     DoCmd.OpenForm "Task Details", acNormal
  5.     Forms![Task Details]![Title] = "Work Order"
  6.     Forms![Task Details]![Start Date] = Now()
  7.     Forms![Task Details]![Employee] = Me.AssignedTech
  8.     Forms![Task Details]![Assignment] = Me.Description
  9.     Forms![Task Details].Refresh
I would still like to know how to do a proper Insert Into from a form. Thanks for your help.
Jun 22 '10 #8
Jerry Maiapu
259 100+
@AccessQuestion
I'll show you a quicker way of inserting data direct into tables without the SQL insert into clause to avoid your enemy so called "You are about to append one record....'. message

Ok..Assuming that AssignedTech, Description and WOID are text boxes on a form try this:
To insert the records/data put a cmd button or so and select an event of your choice and paste the following

Expand|Select|Wrap|Line Numbers
  1. Dim strSQL        As String
  2.   Dim db            As DAO.Database
  3.   Dim rs            As DAO.Recordset
  4.   On Error GoTo ErrorHandler
  5.   Set db = CurrentDb()
  6.   Set rs = db.OpenRecordset("Tasks")
  7.     rs.AddNew ' go to a new record 
  8.     rs!Title = "Work Order"
  9.     rs!Status= "Assigned"
  10.     rs!Start Date = Now()
  11.     rs!Employee = Me.AssignedTech 
  12.     rs!Destination = Me.Description 
  13.     rs!Purpose = Me.WOID 
  14.     rs.Update
  15.  
  16.  MsgBox "Successfully Inserted into table”, vbOKOnly + vbQuestion, "Done"
  17.  
  18. exitHandler:
  19.   Set rs = Nothing
  20.   Set db = Nothing
  21.   Exit Sub
  22.  
  23. ErrorHandler:
  24.   Select Case Err
  25.     Case Else
  26.       MsgBox Err.Description
  27.       DoCmd.Hourglass False
  28.       Resume exitHandler
  29.   End Select
  30.  
  31.  

If you see the message Successfully Inserted into table then your records must have been already inserted into table, go to table and cross-check. Hereafter, you can delete line #16.; it is only for demo purposes here.

Hope this helps

Regards

Jerry
Karex Mangi
Jun 23 '10 #9
NeoPa
32,556 Expert Mod 16PB
I've been monitoring this thread but been too confused to know what to post until the latest set of question.

The usual way to stop the warning messages is to use :
Expand|Select|Wrap|Line Numbers
  1. Call DoCmd.SetWarnings(False)
It's good practice to follow this with the reverse when the SQL has been run as otherwise your software is changing the working environment of the operator. EG :
Expand|Select|Wrap|Line Numbers
  1. Call DoCmd.SetWarnings(True)
Jerry's suggestion is also a perfectly viable way to handle this situation of course.

When working with SQL from within VBA it may help you to know about the following :
One of the most popular (frequently occurring rather than best liked) problems we get is with SQL strings being manipulated in VBA code.

The reason this is so difficult is that all the work is being done at a level of redirection. What I mean by this is that the coder is never working directly with the SQL itself, but rather with code which in turn, is relied on to produce the SQL that they are envisaging is required. It's rather similar to the problems coders have historically had dealing with pointers.

Anyway, a technique I often suggest to coders struggling with this (at any level. This happens to experienced coders too.) is to use either the MsgBox() function, or Debug.Print into the Immediate Pane of the debugger window, to display the value of the SQL in the string before using it (That's assuming you're not good with debugging generally. Personally I would trace to the line, then display the value prior to allowing execution of the string - See Debugging in VBA). It's really much easier to appreciate what a SQL string is meant to do, and where there may be problems, when you can see it in its entirety, and in its true form, rather than as the code is about to create it.
Jun 23 '10 #10

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

Similar topics

1
by: Tobias Oberascher | last post by:
Good Morning, everybody! I've encountered big problems with one of my file-fields, which was implemented for uploading files. Some of my users don't have any problems at all - the...
2
by: nsj | last post by:
how to display text in new line in a TextBox in Vb.NET?
0
by: Jorge_Beteta | last post by:
I'm programming with ASP NET and Crsytal Report 9.0. I design in VS 2003 IDE. In design time, I just insert Image01.bmp (ICrOleObject) onto my Crsytal Report. It appears fine on the report in...
2
by: Ned | last post by:
I am trying to use a CustomValidator on a textbox. The Validator uses a client-side funtion but it doesn't run if the textbox is empty. If there is data in the text box it runs fine. Any...
0
by: Pietro | last post by:
I've created a summary text for a class, but it doesn't appear whem i add it to another project, i can see it only in the same project. Thanks Pietro
1
by: Pietro | last post by:
I've created a summary text for a method of a class, but it doesn't appear whem i add it to another project, i can see it only in the same project. Thanks Pietro
2
by: Dabbler | last post by:
I'm using a gridview bound to an SqlDataSource. If the table is empty the gridview doesn't appear on the page. Is there a way I can force the empty gridview to appear to allow inserting new rows? ...
6
by: Ole | last post by:
Hi, I'm running a command line process from my C# application trying to catch the output messages from the process into a textbox in my windows form. But the text doesn't update (the ReadLine...
5
by: michels287 | last post by:
Right now I have a touchscreen with a virual keyboard. I would like to create arrow keys. If the user messed up the inputted text, he can move the blinking cursor left one space at a time between...
2
by: =?Utf-8?B?RXRoYW4gU3RyYXVzcw==?= | last post by:
Hi, I am using C#.net 2.0 to write a web application. I would like to be able to programmatically detect what text has been selected in a textbox control. Is this possible? If not, is there some...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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
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...
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...
0
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...
0
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.