8 Replies - 2689 Views - Last Post: 30 September 2014 - 03:57 AM Rate Topic: -----

#1 Pokey!   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 26-September 14

Get Current Date Stamp And Fill Into Text Box With Button Click Event

Posted 26 September 2014 - 11:33 AM

Hi Experts,

We use epicor's Vantage 8.
I am trying to get a text box automatically filled with the current date / user stamp when I click a button.
I know how to make a button click event and construct the string for the information I need.The text box has EpiBinding HDCase.IssueText (= table.field).

In the text box the users are typing their notes. The current date and username must be automatically filled in the text box after the last note when they click the button.

I made a Msg.Box in the code that I have so far to check if the result of my constructed string is ok. But now I need some help with the code to assign the result into the text box. Actually a lot of help because I just starting to learn the code language, so take it easy on me please ;)/>

This is what I have so far:

Private Sub btnEpiCustom2_Click(ByVal Sender As Object, ByVal Args As System.EventArgs) Handles btnEpiCustom2.Click 
 '// ** Place Event Handling Code Here ** 
 dim UserName As String = Environ("Username") 
 dim CurrentDatestamp as string = Now() 
 dim str = String.Format("{0:dd/M/yyyy} {1} :", Date.Now, Environment.UserName) 
 MsgBox (str) 
 End Sub 


Any help would be appreciated,

Regards,
Pokey

Is This A Good Question/Topic? 0
  • +

Replies To: Get Current Date Stamp And Fill Into Text Box With Button Click Event

#2 _HAWK_   User is offline

  • Master(Of Foo)
  • member icon

Reputation: 1162
  • View blog
  • Posts: 4,444
  • Joined: 02-July 08

Re: Get Current Date Stamp And Fill Into Text Box With Button Click Event

Posted 26 September 2014 - 11:48 AM

Replace Textbox1 with the name of your textbox.

Textbox1.Text = String.Format("{0:dd/M/yyyy} {1} :", Date.Now, Environment.UserName)

Was This Post Helpful? 1
  • +
  • -

#3 Pokey!   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 26-September 14

Re: Get Current Date Stamp And Fill Into Text Box With Button Click Event

Posted 26 September 2014 - 01:03 PM

Thank you Hawk, I will try this monday at work and let you know about the result.

Regards,

Pokey!
Was This Post Helpful? 0
  • +
  • -

#4 Pokey!   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 26-September 14

Re: Get Current Date Stamp And Fill Into Text Box With Button Click Event

Posted 29 September 2014 - 01:05 AM

Hi Hawk and other experts,

it did not worked. I am getting a compile error: Name 'txtIssueText'is not declared.
This was the code I was trying.

Private Sub btnEpiCustom2_Click(ByVal Sender As Object, ByVal Args As System.EventArgs) Handles btnEpiCustom2.Click
		'// ** Place Event Handling Code Here ** 
		dim UserName As String = Environ("Username")  
		dim CurrentDatestamp as string = Now()  
		txtIssueText.Text = String.Format("{0:dd/M/yyyy} {1} :", Date.Now, Environment.UserName)
	End Sub


In our system 'HDCase' is the table and 'IssueText' is the field (TextBox) with property name txtIssueText.

The next thing I was trying to do was to declare it, but I thing I am completely off track now.

Private Sub btnEpiCustom2_Click(ByVal Sender As Object, ByVal Args As System.EventArgs) Handles btnEpiCustom2.Click
	'// ** Place Event Handling Code Here ** 
	dim UserName As String = Environ("Username")  
	dim CurrentDatestamp as string = Now()
	dim txtIssueText as TextBox  
	txtIssueText.Text = String.Format("{0:dd/M/yyyy} {1} :", Date.Now, Environment.UserName)
End Sub



It compiled successfully but the currect date / user is not entered into the tekst box when I click the button.
Nothing is happening.

Could you or anyone else help me a bit further?

Thanks,

Pokey!
Was This Post Helpful? 0
  • +
  • -

#5 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6834
  • View blog
  • Posts: 28,360
  • Joined: 12-December 12

Re: Get Current Date Stamp And Fill Into Text Box With Button Click Event

Posted 29 September 2014 - 04:17 AM

This
dim txtIssueText as TextBox

is creating an entirely new reference to a TextBox object, it has no connection (currently) to any TextBox on your form.

What is the name of the TextBox that you wish to update? Click on it, and look for its name in the Properties window. Then
txtBoxName.Text = "whatever value you want to set it to"

Quote

We use epicor's Vantage 8.

I have no idea what this is, but a TextBox is a TextBox and has a Name property.
Was This Post Helpful? 1
  • +
  • -

#6 Pokey!   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 26-September 14

Re: Get Current Date Stamp And Fill Into Text Box With Button Click Event

Posted 29 September 2014 - 05:10 AM

Hi andrewsw,

you are right: I had to assign the string to the property of the textbox like this;

Private Sub btnEpiCustom2_Click(ByVal Sender As Object, ByVal Args As System.EventArgs) Handles btnEpiCustom2.Click
		'// ** Place Event Handling Code Here ** 
		dim UserName As String = Environ("Username")  
		dim CurrentDatestamp as string = Now()
		dim txtIssueText = CType(csm.GetNativeControlReference("GUID from Properties"),EpiTextBox)
		dim str = String.Format("{0:dd/M/yyyy} {1} :", Date.Now, Environment.UserName)  
		txtIssueText.Text = str
	End Sub


And I am closer to the solution now.

It compiled successfully and does the trick almost right because the comments are completely replaced by the datestamp when I click the button but I want the datestamp placed after the last comment and a blank space every time the button is clicked.

Like this for example;

---textbox------------------------------
28-9-2014 timk:
I have instructed the customer to repair the items.

29-9-2014 johnd:
I have sent the customer a drawing.

29-9-2014 timb;
---------------------------------------

So what do I have to adjust to the code to keep the comments in place and just place a datestamp after the last comment?

Thank you,

Pokey!
Was This Post Helpful? 0
  • +
  • -

#7 Pokey!   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 26-September 14

Re: Get Current Date Stamp And Fill Into Text Box With Button Click Event

Posted 30 September 2014 - 02:38 AM

Hi,

another forum helped me out with the final code I needed.
This was the winning code for me:


Private Sub btnEpiCustom2_Click(ByVal Sender As Object, ByVal Args As System.EventArgs) Handles btnEpiCustom2.Click
			'// ** Place Event Handling Code Here ** 
			dim UserName As String = Environ("Username")  
			dim CurrentDatestamp as string = Now()
			dim txtComment = CType(csm.GetNativeControlReference("GUID property"),EpiTextBox)
			dim str = String.Format("{0:dd/M/yyyy} {1} :", Date.Now, Environment.UserName)  
			txtComment.Text = txtComment.Text + Environment.NewLine + Str
		End Sub 


Regards,
Pokey!
Was This Post Helpful? 0
  • +
  • -

#8 andrewsw   User is offline

  • never lube your breaks
  • member icon

Reputation: 6834
  • View blog
  • Posts: 28,360
  • Joined: 12-December 12

Re: Get Current Date Stamp And Fill Into Text Box With Button Click Event

Posted 30 September 2014 - 03:05 AM

Here's one forum: ittoolbox. How many more were there competing to be the winner..?
Was This Post Helpful? 1
  • +
  • -

#9 Pokey!   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 9
  • Joined: 26-September 14

Re: Get Current Date Stamp And Fill Into Text Box With Button Click Event

Posted 30 September 2014 - 03:57 AM

Hi andrewsw,

the one you mentioned was indeed the winner.
I had put my question also on vbforums.com.

thank you also for your time and effort,

Regards,

Pokey!
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1