View Full Version : Help with Form Code
CORYWP
12-06-2006, 11:34 AM
I get a compile error when this code is run, The red portion is what is high lighted by the the debugger. I have checked all the text box names that the code refers to make sure they match and they do. This is someone else's code that I had to alter to make usuable for a different database. It is meant to create a new record in the table, but some fields require formatting so the thats where the problem occurs.
Any help would be greatly appreciated.
Private Sub Command28_Click()
DoCmd.GoToRecord , , acNewRec
Me.PlantNo.Value = Me.PlantNox
Me.UnitNo.Value = Me.UnitNox
Me.ServiceCode.Value = Me.SCX
Me.TrainSeqNo.Value = Me.TrainSeqNox
Me.LineSize.Value = Me.LineSizex
Me.LineClass.Value = Me.LineClassx
Me.DrawingNo.Value = "ISO" + "-" + Me.UnitNox + "-" + Me.SCX + "-" + Me.TrainNoSeqNox + "-" + "01"
Me.LineNo.Value = Me.LineSizex + "-" + Me.SCX + "-" + Me.TrainSeqNox + "-" + Me.LineClassx
Me.ISOID.Value = Me.UnitNox + Me.SCX + Me.TrainSeqNox + "01" + ".i01"
Me.Text57.Value = "Drawing Number " + "ISO" + "-" + Me.UnitNox + "-" + Me.SCX + "-" + Me.TrainNoSeqNox + "-" + "01" + " Has Been Added " + "And Line Number " + Me.LineSizex + "-" + Me.SCX + "-" + Me.TrainSeqNox + "-" + Me.LineClassx + " Has Been Added"
Me.SheetNo.Value = "01"
Me.NewLine.Value = True
Me.NewDate.Value = Now()
DoCmd.DoMenuItem acFormBar, acRecordsMenu, acSaveRecord, , acMenuVer70
DoCmd.DoMenuItem acFormBar, acRecordsMenu, 5, , acMenuVer70
End Sub
I am colour blind so I can't see any "red" portion but you can't use the "+" sign for concatenating (adding) string data to a string.
You use the "&" instead.
CORYWP
12-06-2006, 11:53 AM
That is not the problem although thank you for the quick response. The "+" works just fine. I have used it before in access on other forms and it has worked. It also was in the original code and that form worked properly. I have tried renaming the textbox that shows the error but that does not help either. All of the field names not ending in X are from my table the fields ending in x are from my form.
CORYWP
12-06-2006, 12:34 PM
its underlined
Me.DrawingNo.Value = "ISO" + "-" + Me.UnitNox + "-" + Me.SCX + "-" + Me.TrainNoSeqNox + "-" + "01"
mdmackillop
12-06-2006, 02:56 PM
Hi Cory,
As you're using this value earlier, I presume this line is working.
Me.ServiceCode.Value = Me.SCX
CORYWP
12-06-2006, 03:18 PM
It doesn't like the .SCX where I highlighted it, if i remove it completely it moves on to another one that it does not like. So I think the problem is larger than just one label.
mdmackillop
12-06-2006, 03:59 PM
Are you mixing strings and numbers? did you try "&" instead of "+" as suggested?
CORYWP
12-06-2006, 04:53 PM
Yes I did, and did not help
CORYWP, any chance of posting an Example database so we can look at it?
One thing that I don't quite understand is that you are referring to all of the parts of the equation using the
Me.
which is the current field values of the current form.
Are you using the the values from a previous record to create a new record or copying one current field value to another current field?
Just a thought, but try changing the field name. *.SCX is a file extension for Visual Fox Pro.
CORYWP
12-07-2006, 09:42 AM
The Text box's on the form are labeled ending in X, the corresponding Field in the database is without the X. I am creating a new record from the input into a form. So the user enters the data into the 6 "x" text box's listed first in the code and then that info is used to fill in certain required fields for a new record. Where should I post the database?, its under 3MB.
EDJ, the .SCX is the problem but it has nothing to do with it looking like a file name extension, when I change the name of the text box and update the code to match the problem still exists.
CORYWP, the database has to be zipped to put it on here. You use the "Go Advanced" button below the "reply" box and then you use the "Manage Attachments" section that appears below the new "Advanced Reply " box.
Browse to your zipped file and then "upload" it.
Any reason why the data doesn't go straight in to the record?
It would mean that your VB would only be dealing with one set of fields, the data can still be manipulated after each field entry by using the field's "After Update" event procedure.
CORYWP
12-08-2006, 12:38 PM
I am out of the office today so unfortunately I wont be able to get back to this problem until Tuesday. I will consider what you said about using the fields directly and the after update procedure, I should of thought of that already. I will let you know what I come up with on tuesday and post the database if necessary.
Thanks,
CORYWP
12-12-2006, 06:24 PM
Ok the file zipped is sill 450KB with just my table and the form. So it is to big as is to upload. I will try the after update procedure.
Cory, I have emailed you the fix.
CORYWP
12-13-2006, 11:49 AM
Thank you, that did the trick. I feel dumb.
Cory, don't feel bad, it was the VB Editors fault by highlighting the wrong field.
Powered by vBulletin® Version 4.2.5 Copyright © 2025 vBulletin Solutions Inc. All rights reserved.