Tracking Forums, Newsgroups, Maling Lists
Home Scripts Tutorials Tracker Forums
 
  HOME    TRACKER    Visual Basic




Setting Label.Caption From A Date/Time Field Value


Hi,I need to set a labe's caption to a date/time field from a SQL database. I have setup the connetion string and all and I define this variable in VB:Dim dtDate As DatedtDate = rsInfo.Fields("UploadDate").ValueThe Field "Upload Date" looks like this:4/27/2001 11:12:09 AMBut my label's caption show up like this:12:00:00 AMHow can I set it correctly????? Please Help,Herick




View Complete Forum Thread with Replies

See Related Forum Messages: Follow the Links Below to View Complete Thread
Setting Label Caption During Startup
I'm writing a Word Macro in VB6. How can I set the Caption setting with a variable as it starts up. I want to do this:


Code:
CurrentUser.Caption = CMNGetUserName()
CurrentPath.Caption = "\SERVER$" & CMNGetUserName() & ""
But if I put it at the top it says Invalid Outside Procedure, not suprising, but I don't know what to do!

Setting Label Caption With Variable
Hi

I am trying to set the caption of a label with a variable name.
ie. Label3.caption = "Test"

I have 12 labels on a form. I would like to create a loop to set all labels to 'Test'

eg. Dim i as Integer
for i=1 to 12
label & i. caption = "Test"
etc, ect...


I am unsure of the syntax to do this.
Any help would be appreciated,
Thanks

Kelly

Setting A Label Caption To Display Variable String
Hello!
I posted a question a little bit ago, which was answered and have moved on to a new question. Once again I am new at this. (couple of days).


I am trying to make a label caption display a variable string.

Code:

Private Sub Age_Display_Click()
Age_Display.Caption = Age
End Sub

The Label is: Age_Display
The variable is: Age

If I click on the label then the variable will show up, but I want it to automatically show, Changing the Label's caption.

I have properly declared all variables, as they are being recognized when I click on the label. As well as have defined the variable.

I tried using:
Private Sub Age_Display_Change()
instead of:
Private Sub Age_Display_Click()

But I don't know.

Thank you,
Kevin Heeney

Setting Width Of Label Based Upon Caption Contents
How can I determine how wide to make a label based upon the contents of it's caption? I want the label's width to be just a little wider than the contents of the caption.

Thanks

Pulling Recordset Field For A Label.caption
i'm in the finishing stages of a print/print preview utility for a label /forms designer wherein the user can print multiple labels on one page

i have no problems doing the layout for every controls. my problem is how do i retrieve these values from a database. one is a text field, while the other is a ole/blob image field.

please help
thanks

ferdz

Changing Label Caption At Run-time
I have a label on my DataReport, and I want to change its Caption at Run-time.

The label is located on Section 4.

How to do so?

Changing Label Caption Of DataReport In Run-time
Hi,

In my DataReport, I have a Label in Section 4. I want to change the Caption of this label during Runtime. How to do so ?

Label On Top Of A Picture Box Does Not Display The Caption At Run Time
hi! I am trying to create my own custom component for displaying and scrolling text. The way I am trying to achieve this is by having a PictureBox so I can set it's picture to whatever image I wish to to. I have 4 labels added on top of the textbox and the text is visible in the design mode but when I run the project the text is not displayed.
Can somebody please tell me why that is and if there is a way to display text on a textbox or form without making use of labels?!

Thank you

Setting Long - Short Date Format In Date Time Settings
How can i set the Date Time Setting Format in Control Panel

i m usiing window Xp


also i want the date format in dd/MM/yyyy

Setting A Date Field Blank
Hi All,
I have an Access Database, and when I try to set a date field in it to nothing in my VB program (I've tried "" and Null) it doesn't like it. The field in the access table has Required set to no, and i don't know why this happens.

Can anyone help?

Thanks,

Adrian Osmond.

Time, Date And Msgbox Caption
Hey ppl, does anyone know the code to make my app display the time and date as a label?
I also would like to know how to change the title of a msgbox, I tried:
MsgBox.caption = "Hello" & MsgBox = "Welcome to this application" but something went wrong and it didnt work, any ideas anyone?
Any help would be much appreciated

Grouping By Date Where Date Field Is Date/time
I have an SQL7 database storing datetime data, and totaliser reading, new records are added every 5 minutes.

I have written the following sql to give me the the min and max totaliser reading for each day - which works fine - except that the resultant Date field is a text field not a date field so the order statement generates an incorrect listing if the data selected sarts in one month and ends in the next, eg.

select left(Date, 12) as Date, Min(Reading) as Day_Start, Max(Reading) as Day_End from Steam where tag_no = 2 and (Date <= '24-November-2005 00:00:00' and Date >= '22-October-2005 00:00:00') Group By left(Date, 12) order by Date asc

Is there another function I can use to extract just the date from the date/time field as a date data type?

I cannot alter the database as its structure is predetermined by the remote field device supplying the data.

Only Want Date Part Of Date Time Field
How can I using an SQL statement just reitrieve the date part of a database field.

The data is stored as 10 05 2001 12:31.

At moment sql is bringing back the whole field. For grouping purposes I only want the date ie 10 05 2003.

Any ideas??

Label Box For Date And Time
So I have a label called lbldatetime

I have it currently set to

Private Sub Form_Load()
lbldatetime = Date + Time
end sub

now when it runs it gives me a snapshot of what the date and time is when the program is currently executed... is there any way that I can make that lbl active meaning that its showing current date and time while the program is running so its active???

Run Time Error When Setting Pivot Field Orientation To XlHidden
Hi there

I've got a client who's encountered a run time error with the program code posted at the bottom of this post. The error happens in the first For loop, when setting the pivot field orientation to xlHidden. That line generates a
Quote:




Run time error 1004: Unable to set orientation of pivot field




message.

The client is running this code in a VBA application in Excel 2000, which makes this error sound like the known problem cited in Microsoft's knowledge base (). However, he has Service Pack 3 for Office 2000 installed (according to the Excel Help...About dialog box), which should fix that problem.

I have tested this code on another machine with Excel 2000 SP-3, processing the same pivot table as my client, and the code runs without problems.

Is anyone aware of another reason why this code might fall over in this way, for my client but not for me?

I should add that I'm only able to contact the client by 'phone and email, so I can't check his system setup easily.

Thanks

Phillippe

Here's the code:
_____________________________

Code:
Sub clear_table(pvttbl As PivotTable)
'
' Subroutine to "clear" a pivot table. In reality
' it just hides all of the fields in the table.
'
Dim pvtfield As PivotField

With pvttbl
For Each pvtfield In .DataFields

Yellow Code:
pvtfield.Orientation = xlHidden

Next pvtfield
For Each pvtfield In .VisibleFields
pvtfield.Orientation = xlHidden
Next pvtfield
End With

End Sub

________________________________________

Setting The Date && Time
I'm looking to include a form to set an "Alarm". The windows "Date & Time" tab as shown in the attachment would be an ideal layout for what I want. I have looked for a code example but have been unsuccessful. Can anybody point me in the right direction?

Thanks.

Date And Time Setting
would someone give me the idea or codes on how could I set the 'time and date' in a distributed network using Visual Basic.? t.y.

Time, Date Stamp Label?
How can I make a label display the current computer time and date when a command button is pressed?

Current Date And Time Label
How do I create a label that shows the current date and time?

Setting The System Time && Date
Is there anyway (w/code) to set the System Date & Time?

Many Thanks,

Setting System Date N Time
how to set the system date and time inside MySQL database. so everytime i no need to key in this 2 field. like access where we can set it i.e Date() and Time(). but i try this in MySQL but it can't work.

Setting The Date/Time Format
How would I set a Date/Time column in Access to format it as a "Medium Time" or "Long Date" like you can when your just creating a DB in access?

Multiple-Step Operation Generated Errors When Setting Date Field To Empty Or Null
I have a form with a bunch of bound controls and a few are date fields. When I try to clear out a date that has been previously set in the record I get the Multiple-Step Operation Error -2147217887(8004e21) The database allows nulls for these date values, so it is OK at the DB level - looks like the ado is causing the problem.

DB is SQL Server 2000

I found the following on Microsoft's site that is directly related to my problem - looks like there is no workaround according to them.

http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q247/2/02.asp&NoWebContent=1

Anyone else have any ideas? There is to much invested in using the bound controls at this point - I cannot abandon this method.

Setting Remote Computer Date & Time
Hi,

anyone know how to set date and time for a remote
computer/pc ?

thanks before,
ari

Setting Alerts For Future Date/time
hi everyone, i'm having a bit of a problem with retrieving a recordset...i don't know why it's not working because i've done it the same way many times already...i'm trying to pull records from an Access 97 database using ADO. i think i must be missing something somewhere...anyone able to see why it's not returning any records?
Code:
Private Sub Timer1_Timer()
strShowAll = "SELECT * FROM `tblAlarms` WHERE `ToUserName` = '" & user & "'"
sconnect = "Provider=Microsoft.Jet.OLEDB.3.51;Data Source= \ServerauMerchantDB.mdb"
Set connShowall = New ADODB.Connection
    connShowall.Open sconnect
Set rsShowAll = New ADODB.Recordset
    rsShowAll.CursorLocation = adUseServer
If rsShowAll.State = adStateOpen Then
    rsShowAll.Close
    Set rsShowAll = Nothing
End If
    rsShowAll.Open strShowAll, connShowall, adOpenDynamic, adLockBatchOptimistic

If rsShowAll.EOF Or rsShowAll.BOF Then
rsShowAll.Cancel
ElseIf Not rsShowAll.EOF Or Not rsShowAll.BOF Then
rsShowAll.MoveFirst
End If

For i = 1 To rsShowAll.RecordCount ' Read all the records from database
'do stuff here
    
    If (tmpDate <= Date) And (tmpTime <= Time) Then
              fillpopup ' fill the popup form
              frmAlarmView.Show ' show popup form
      Exit Sub
End If
rsShowAll.MoveNext ' read next record
Next i
rsShowAll.Close
Set rsShowAll = Nothing
End Sub

when i set a breakpoint at: For i = 1 To rsShowAll.RecordCount , the recordcount = -1 when i hold the mouse over...there is a record in the database, and the ToUserName field does = user1
Thanks!



Edited by - mrsmiley0221 on 1/8/2004 7:35:43 AM

Setting The System Or Local Date And Time
Howdy!

This is probably an old question, but I've still got no good answer. Does anyone have
any running source on how to set the system or local time, written in evb?

Thanks in advance....

 

Date Time Field
I have a table field that store date and time in the format of yyyy/mm/dd hh:mm:ss, how can i select the date only ?

Date & Time As Field Name
Hi all,



I have an application that reads the dbf file for data input, the application is working fine, except for some reasons it stops responding , means fails to read the dbf file.

The said dbf file contains two fields as Date & Time , the vb applications reads this fields first, is this the reason for system not responding.



Regards

JOhn

Date Being Put Into Field As Time
Hi,

I'm trying to add a date value to a field in access using SQL but it's showing up as a time.

Both the table and date field are being created at run-time.  

The code used to create the "dDate" field is:
"ALTAR TABLE Table1 ADD COLUMN dDate DATE"
- This seems to create a Date/Time field just like any other.

The code I used to add a date value is
"UPDATE Table1 SET dDate = " & "01/01/2006"

I've also tried a date variable and a string variable formatting both as dates, not formatting either ...  No matter what I do, it just inputs a time value.

All this is being done from outside of Access using VB & SQL.  

Any comments and/or instructions would be greatly appreciated.  Thanks in advance.

Paolo


Add X Days To Date/time Field
Hello

I have a texbox (txtReceivedDate) that is populated from my MS Access Database Field receivedDate that is set to date/time.

What I am trying to do is add 10 days to the receivedDate and have that NEW date appear in my txtbox (txtNewDate)

Example: txtReceivedDate would be 7/28/2004 and the txtNewDate would be
8/07/2004

Any help with this would be appreciated

Tks
Bill

ADO Changing Time And Date Field???
How can I update a "DateTime" field in table.dbf with a date time value that does not take on the format that is set in the Windows "Regional Settings"

My Regional Settings are for short Date yy/MM/dd

My code is a follows:
Dim rs As adodb.Recordset
Set rs = New Recordset

rs.Open "Select * From table.dbf", "filedsn=mydsn;", adOpenDynamic, adLockOptimistic

rs.AddNew
rs!Timestamp = Format(Now, "mm/dd/yy")
rs.Update
rs.Close

When I look in table.dfb the date is stored as yy/MM/dd not as mm/dd/yy

Thanks in advance

Jeremy

How To Detect A Date/Time Field ?
I need to know how to determine a Date/Time field from an Access database, rs!inputdate is a Date/Time field, I use RS.ADDNEW to create this record but I did not write anything in it. But following is not working:

rs!inputdate = ""
rs!inputdate = Null
rs!inputdate = 0
rs!inputdate = vbNullString

Please help .....

How To Erase Date And Time Field
I have 2 fields defined as DAT/TIME. Returned_on has a DATE and Returned_at has TIME. How can I erase them thru the application?

I am using Access data base in my VB6 application.

UPDATE Contracts SET Returned_on = XX, Returned_at = YY WHERE Cont_id = 1

What should I set my XX and YY to.

Date And Time In A Single Field
In a SQL table what is the format to insert the date & time in single datetime field through VB 6.0

Setting File Date/Time Stamps With 16-bit Function Calls?
OK, I know how to do this with 32-bit function calls, but there don't seem to be equivalent functions in the 16-bit DLLs...but there must be a way! I need to set a file's date/time stamp to a certain time. There is a specific reason that I MUST write this program using VB3, which means I can use only 16-bit function calls.

I don't want to set the computer's clock, write to the file, and set it back. That is clumsy and there has got to be a more elegant way! Can anyone help please?

Filling Date/Time Field With NULL
Shalom,

I have a Date/Time field in a Microsoft Access 2000 database and I need to fill it will nothing (NULL). Here is my current statement:


Code:
gtSQLStmt = "UPDATE TICKET_DETAILS SET" & _
" sched_dte = '" & Null & "', " & _
" alert_user = 0" & _
" WHERE index_num = " & Val(txtIndexNum)

StdLibDB.execute_sql_sub gtSQLStmt, adoConA
When I execute this code I get the following error:

"Data type mismatch in criteria expression"

(this is on the execute_sql_sub line which executes my sql of course)

How can I put a NULL or nothing in that Date/Time field?

GrayKnight

Addition To Date/time Field In Oracle
Hi Guyz,

Q1
Lets say i have the following data in the date time field..

6/25/2004 7:02:31 AM

How do i add another 8000seconds to this data in oracle?

Q2
And how do i search, for an example, give me all the list of data with 6/25/2005, no matter what time it is.
I tried using the like operator but it doesnt seem to work..

Any ideas?

thankx in advance

Clear ACCESS Date/time Field
The following code is a test to set a date/time field in ACCESS to a date and then try to set it back to a blank (clear the field). Setting the field to a valid date works ok, but when I try to clear out the field, I get a "Type Mismatch" error.

Does anyone know how to blank out a date time field from VB?



Code:
Private Sub Command_Click()
Set cndb = New ADODB.Connection

cndb.Open "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=c:master.mdb;Persist Security Info=False"


Dim rs As ADODB.Recordset
Set rs = New ADODB.Recordset
rs.Open "SELECT * FROM Shiplist WHERE [Order ID] = 'BL00004'", cndb, adOpenDynamic, adLockBatchOptimistic, adCmdText

If rs.EOF Then

Else
Debug.Print rs![Expected Ship Date]
rs![Expected Ship Date] = "9/2/2005"
rs.UpdateBatch

Debug.Print rs![Expected Ship Date]
'the next line will cause a "Type Mismatch" error
rs![Expected Ship Date] = "" 'trying to set the date/time field to a blank
rs.UpdateBatch

End If

rs.Close

Set rs = Nothing


cndb.Close

Set cndb = Nothing
End Sub
tia,
flynn

Date/Time Field - Select Returning Nothing
Hi all,

I have a vb app with an access 2000 db. The problem is that I have a field in the db called DateAtt where the type is Date/time (shortdate - dd/mm/yy). When I try to select values from this field vb returns a recordcount of 0.

I understand that you can enclose the date within 2#'s (date literal), but when I do this the recordcount is 0 even though the date entered exists in the db. This is because eg. the record 14/03/04 (in the db - dd/mm/yy) <> 03/14/04 (from the sql query mm/dd/yy).

sql = "Select DateAtt from Att where DateAtt = #" & dateEntered.text & "#"

Is there a way of getting around this problem and could you provide the sql for this? Could you use the date type instead of literals?

Also is there a way to select a date where the day is not known therefor bring back all records which have a month 03 and year 04. So in other words is there a way to put the % infront of the date selected (in this case just being the month and year). So it would look like %/03/04?

Thanks in advance!

Searching An Access Date/Time Field?
Good Morning.
I am having trouble searching an Access(2000) DataTime Field.

The field holds both the Date and Time: But I only want to search this field by the Date.

Below is my search string it returns no records. (Does not give an error, just no records.)

searchsql = "select * from slog where wdate=" & Chr$(35) & FormatDateTime(DTPicker2.Value, vbShortDate) & Chr$(35)

Select Statement With A Date/Time Field
Howdy!

I want to pull all records from earlier than 2 two days ago.
I am using Access97,with a Date/Time field, but I can not get the thing to work.

Here's what I have

Dim TimeLapse
Dim SQL

TimeLapse = Now - 2

Set adoMasterRS = New Recordset

SQL = "Select * from Master where RowUpdate >= '" & TimeLapse

adoMasterRS.Open SQL, db, adOpenStatic, adLockOptimistic


Thanx

Insertin Date And Time On Datetime Field
Hi everyone,


Do you guys know how to insert date and time values on a single SQL Server datetime field using ASP or VB?
I've tried using Convert but it doesn't seem to work... I always get error messages.

Thanks a lot.

Otavio

Comparing Date Time Stamps Field
I have a date time stamp field in my database. And i need to count calls for one day. So my sql statement looks something like this :
Code:
                Dim bdwsmtCon As New Odbc.OdbcConnection("Driver={MySQL ODBC 3.51 Driver};server=192.168.2.5;port=3306;database=bdwsmt;pwd=knicks24;uid=tmstms;")
                Dim bdwsmtCommande As New Odbc.OdbcCommand
                Dim bdwsmtReader As Odbc.OdbcDataReader
                Dim strSQL As String 'Select statment
                Dim curDate As String 'curDate
                Dim endDate As String 'end string for sql statment
                curDate = startDateTimePicker.Value.AddDays(dblStartDay).ToString("M/d/yyyy")
                endDate = startDateTimePicker.Value.AddDays(dblEndDay).ToString("M/d/yyyy")
                    strSQL = "SELECT Count(*) AS MyCount FROM wab_answers WHERE answerTime > #" & endDate & " 11:59:59 PM# AND answerTime < #" & curDate & " 11:59:59 PM# AND wabScreen=1;"
                    MsgBox(strSQL)
                    bdwsmtCommande = New Odbc.OdbcCommand(strSQL, bdwsmtCon)
                    bdwsmtCommande.Connection.Open()
                    bdwsmtReader = bdwsmtCommande.ExecuteReader(CommandBehavior.CloseConnection)


The error is the # # round my date and time. I tried to use ' ' around them but that just gave me 0 for the count. Any Ideas?

How To Insert In A Date/Time Field In MS Access
I always get the error: "Invalid operand for operator: <assignment>"

I tried '1997-01-01' or '19970101' or '01011997' or '01-01-1997' .. and many others with "/"

Nothing works ...

Ado (command) Updating Date/time Field
Hi,
I'm trying to update a field of type date/time to null value using sql query.

my sql query:
"Update jobs Set mydate.value = DBNull" ....

This doesn't work!
What do I need in this sql statement so that I can update date/time field with nothing (empty).
Thanks.

Activex Control For Date/Time Field
Hi,


Can anybody suggest me an activex control accepting Date and Time. For Date i found many Callendar controls(eg. sheridan) but i need a similar control for Time. All suggestions are welcome.


Thanks in Advance


Chandu

Returning A Date/Time Field To Empty
I am accessing a database in the following manner:

set db = OpenDatabase("c:Databasename.mbd", false)
set rec = db.openrecordset("tblName",dbOpenDynaset)
rec.MoveFirst
Do Until rec.eof
With rec
.Field("date")=vbNull
.MoveNext
End With
Loop




It continues to fill the date with "12/31/1899"

I can't figure out how to just delete the information in the field so that it is empty.

Jason Hatt

Problem Storing Date/Time In TEXT Field.
Hi,

I have an Access Table with a field called "VisitDate" and is a Text Field of size 50. I want to store current Date and Time in this field.

My program stores current date and time in a variable "ProgramDate" which is of Date DataType

I tried following code, but it generates this error:

Run-time error '-2147217887 (80040e21)'
The field is too small to accept the amount of data you attempted to add. Try inserting or pasting less data.

Code:
Dim myDateTime As String

myDateTime = CStr(ProgramDate) + " " + CStr(Time)

rsTempReport!VisitDate = myDateTime
I want to store data in this format, e.g: 23/9/2005 11:15 AM

Create Date/Time Field And Loading Default Value
I am trying to add some fields programmatically to a database using DAO. I need to load some default value to the date/time fields in order that they ar not null. Here is what I tried:

xs = ""
On Error Resume Next
xs = db.TableDefs("Department").Fields("begHH").Name
On Error GoTo 0
If xs <> "reciprocal" Then
db.TableDefs("Department").Fields.Append _
db.TableDefs("Department").CreateField("begHH", dbDate / Time)
db.TableDefs("Department").Fields("begHH").DefaultValue = "12:00 AM"
'db.Execute "UPDATE Department SET begHH= "12:00 AM" WHERE
begHH IS NULL", dbFailOnError
End If

It does not like the string of "12:00 AM" at all. Does anyone know what value I should put in the newly created fields. Thanks fo rthe help.

Copyright © 2005-08 www.BigResource.com, All rights reserved