PDA

View Full Version : Entering Date in a form to be pulled to VBA



presence76
03-13-2006, 03:33 PM
I have not created a form in quite a while. I have an Access DB that I have some VBA code that unzips files, seperates them on size and then prints them. The whole process will be started by a user opening up a form and entering in the processing date in a frame. Then ,they click a command button and the macro kicks off the VBA which pulls in the date from the form. Problem is the frame I have created is a Bound Object Frame (I think that is the correct way) but I cannot enter any data in to it. When I open the form and try to put data in the frame I get

"OLE object is empty"
"you cant edit a bound object frame if the underlying table does not contain an OLE object"

I think there is a setting in the properties of the frame that I must be missing. Any help is greatly appreciated. Thanks.

john-86
03-14-2006, 05:11 AM
Hi, I'm fairly new to VBA, so I may well be wrong. If you create an unbound text box on your form (given a name such as 'txtDate') then in the box just type '=Now()'. Then you can refer to this by me.txtDate.value in your VBA code.

Or possibly you could create a table of processing dates and then when the process begins you could retrieve the date using the =Now() and insert it into a table using:


Dim db As Database
Dim rs As Recordset

Set db = CurrentDb()
Set rs = db.openrecordset("tablename", dbopentable)

With rs
.AddNew
.Fields("fieldname").value = me.txtDate.Value
.Update
End With


Dunno if any of that helps.

Regards,
John

presence76
03-14-2006, 05:50 AM
Yes, that is correct and thanks for the reply. I should have been using an unbound text box as opposed to a bound object frame. Works fine now.

john-86
03-14-2006, 05:56 AM
always glad to help m8 :friends:

Regards,
John

presence76
03-14-2006, 07:43 AM
OK, heres one. How do I display a literal on this form. If I make it a textbox and put a literal in it during design, when I open the form I get
"#Name ?" where my literal should be. Thanks in advance for any replies.

john-86
03-14-2006, 07:48 AM
Sorry for maybe askin a silly questions, but what's a literal?

presence76
03-14-2006, 07:57 AM
Something I want to appear on the page, like instrucions on how to use the screen (form). On this form I would like to give it a title like "Vanguard Printing Screen" or something to that effect.

presence76
03-14-2006, 07:57 AM
A literal is a static piece of text. Something I want to appear on the page, like instrucions on how to use the screen (form). On this form I would like to give it a title like "Vanguard Printing Screen" or something to that effect.

john-86
03-14-2006, 08:33 AM
If I'm understanding you correctly you can just do this with a label. You'll find the label tool in your toolbox.

Regards,
John