So all I am doing is passing data from one from into another. -
DoCmd.OpenForm "Task Details", acNormal, , , acFormAdd
-
Forms![Task Details]![Title] = "Work Order"
-
Forms![Task Details]![Start Date] = Now()
-
Forms![Task Details]![Employee] = Me.AssignedTech
-
Forms![Task Details]![Assignment] = Me.Description
-
Forms![Task Details]![cmdClose].SetFocus
-
-
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.
9 4108
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
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]?
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.
@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 - Forms![Task Details]![Assignment] = Me.Description
then on the control source of the Assignment txtbox put this; - =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
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.
By the way, here is the SQL statement I am trying to use to insert from this form into the Tasks table. - 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.
Update: Solved. Not the best thing to do I guess, but I just refreshed the form once the data was passed. - Private Sub Command26_Click()
-
Me.Status = "Assigned"
-
DoCmd.Save
-
DoCmd.OpenForm "Task Details", acNormal
-
Forms![Task Details]![Title] = "Work Order"
-
Forms![Task Details]![Start Date] = Now()
-
Forms![Task Details]![Employee] = Me.AssignedTech
-
Forms![Task Details]![Assignment] = Me.Description
-
Forms![Task Details].Refresh
I would still like to know how to do a proper Insert Into from a form. Thanks for your help.
@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 - Dim strSQL As String
-
Dim db As DAO.Database
-
Dim rs As DAO.Recordset
-
On Error GoTo ErrorHandler
-
Set db = CurrentDb()
-
Set rs = db.OpenRecordset("Tasks")
-
rs.AddNew ' go to a new record
-
rs!Title = "Work Order"
-
rs!Status= "Assigned"
-
rs!Start Date = Now()
-
rs!Employee = Me.AssignedTech
-
rs!Destination = Me.Description
-
rs!Purpose = Me.WOID
-
rs.Update
-
-
MsgBox "Successfully Inserted into table”, vbOKOnly + vbQuestion, "Done"
-
-
exitHandler:
-
Set rs = Nothing
-
Set db = Nothing
-
Exit Sub
-
-
ErrorHandler:
-
Select Case Err
-
Case Else
-
MsgBox Err.Description
-
DoCmd.Hourglass False
-
Resume exitHandler
-
End Select
-
-
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
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 : - 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 : - 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. Sign in to post your reply or Sign up for a free account.
Similar topics
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...
|
by: nsj |
last post by:
how to display text in new line in a TextBox in Vb.NET?
|
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...
|
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...
|
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
|
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
|
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?
...
|
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...
|
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...
|
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...
|
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...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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,...
|
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,...
|
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...
|
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,...
|
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: 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...
|
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...
| |