Dec 7th, 2005, 01:11 AM
#1
Thread Starter
Addicted Member
Dec 7th, 2005, 02:22 AM
#2
Re: How to set current date..??
Hi,
Use the following code in your user form:
VB Code:
Private Sub UserForm_Initialize()
TextBox1.Text = Date
'If you want to change the format of the date use format function
'TextBox1.Text = Format(Date, "DD-MMM-YYYY, HH:mm")
'If you want to display time with the format:
'TextBox1.Text = Format(Time, "hh:mm:ss")
'If you want to display both date and time you can use now function
'TextBox1.Text = Format(Now(), "DD-MMM-YYY hh:mm")
End Sub
_____________
CS.
Last edited by cssriraman; Dec 7th, 2005 at 02:25 AM .
Dec 7th, 2005, 07:08 AM
#3
Re: How to set current date..??
One minor note. You do not need the parentheses with Now.
VB Code:
Text1.Text = Format(Now, ""DD-MMM-YYY hh:mm")
Dec 7th, 2005, 10:43 AM
#4
Thread Starter
Addicted Member
Re: How to set current date..??
Hi All,
Thanks very much for your helps...However, I tried to use your codes but the year was not 2005...it is 3451 or something...what was wrong with it..???..Additionally, I can still write on the TextBox...How should I do in order me could not write anything/re-write on the TextBox1 please???.....Please find my attached file and have a look what was wrong with my codes please...
Thank you for your kind helps...
Best Regards,
Jennifer
Attached Files
Dec 7th, 2005, 12:59 PM
#5
Frenzied Member
Re: How to set current date..??
What's the date format on your system? That looks like a Chinese or Jewish year, except they're something like 4702 & 5766, respectively.
Tengo mas preguntas que contestas
Dec 7th, 2005, 07:33 PM
#6
Thread Starter
Addicted Member
Re: How to set current date..??
Hi All Experts,
Have you open my file and look at it please..???...I just want to make sure the year will be 2005...not like this. i.e. 8-Dec-05342 8:48......Additionally, I can still write up on the TextBox1...what I would like trying to do is when the document is open, the form will automatically come up and show the current date and time on the TextBox1 and anyone could not changed/rewrite the date and time on that TextBox1 (it is looked like a disable for rewriting)...
Anyone could help me for that please...please....
Thanks for all your kind helpfulness...
Best Regards,
Jennifer
Last edited by zach007; Dec 7th, 2005 at 07:52 PM .
Dec 8th, 2005, 04:09 AM
#7
Re: How to set current date..??
Check out the uploaded file.
the date format should be like this:
VB Code:
'To set the date and time in Textbox when loading the form
TextBox1.Text = Format(Now, "DD-MMM-YYYY hh:mm")
'not as
'TextBox1.Text = Format(Now, "DD-MMM-YYY hh:mm")
'To restrict the user not to write in text box
TextBox1.Locked = True
Attached Files
Dec 8th, 2005, 04:12 AM
#8
Re: How to set current date..??
Originally Posted by
Hack
One minor note. You do not need the parentheses with Now.
VB Code:
Text1.Text = Format(Now, ""DD-MMM-YYY hh:mm")
Oops!
the date format in your code is wrong!
should be
VB Code:
Text1.text = Format(Now, "DD-MMM-YYYY hh:mm")
Jan 13th, 2006, 11:28 AM
#9
Thread Starter
Addicted Member
Re: How to set current date..??
Dear Experts,
What additional code should I put if I would like to put a current date on bookmark directly rather than on TextBox....For an example, if I open my word document .i.e. testing.doc, it will automatically show current date on the bookmark....
Anyone could help me please...???
Thank you so much...
Jan 13th, 2006, 11:41 AM
#10
Re: How to set current date..??
VB Code:
ActiveDocument.Bookmarks.Item("CurrentDate").Range.Text = Format(Now, "DD-MMM-YYYY hh:mm")
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Jan 13th, 2006, 11:52 AM
#11
Thread Starter
Addicted Member
Re: How to set current date..??
Hi,
I put this code into "ThisDocument"
VB Code:
ActiveDocument.Bookmarks.Item("bk_date").Range.Text = Format(Now, "DD-MMM-YYYY hh:mm")
But still does not show up automatically when I open that word doc....
Jan 13th, 2006, 11:59 AM
#12
Re: How to set current date..??
In the Document_Open event?
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Jan 13th, 2006, 08:08 PM
#13
Thread Starter
Addicted Member
Re: How to set current date..??
Hi,
I did this:
VB Code:
Private Sub Document_Open()
ActiveDocument.Bookmarks.Item("bk_date").Range.Text = Format(Now, "DD-MMM-YYYY hh:mm")
End Sub
and received an error message: Run Time Error: '6028' The range cannot be deleted.
Jan 13th, 2006, 11:30 PM
#14
Re: How to set current date..??
Does the bookmark exist in that document?
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Jan 14th, 2006, 12:39 AM
#15
Thread Starter
Addicted Member
Re: How to set current date..??
Yes, it is exist. When I save it. Then I re-open the word document then there is an error message: Run Time Errors '6028' - The range cannot be deleted.
Please help me for this....
Jan 14th, 2006, 12:45 AM
#16
Re: How to set current date..??
Attach your most current document and I'll look at it.
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Jan 14th, 2006, 12:57 AM
#17
Thread Starter
Addicted Member
Jan 14th, 2006, 02:58 AM
#18
Re: How to set current date..??
Ok, I got it. Its giving that error from the bookmark being a Date format. you need to set the format of it from the properties context menu item when the bookmark is selected from the goto bookmark via the Insert > Bookmarks... dialog.
Then type in the custom format that you have and it will work.
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Jan 14th, 2006, 03:28 AM
#19
Thread Starter
Addicted Member
Re: How to set current date..??
It works...!!!...Thanks a lot for your kind helps...???....How about the button that I asked to you..??
Jan 14th, 2006, 03:30 AM
#20
Re: [RESOLVED] How to set current date..??
Oh, missed that part. I'll look.
You could also format the bookmark as a Text field instead of a Date field too.
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Jan 14th, 2006, 03:50 AM
#21
Re: [RESOLVED] How to set current date..??
Looks like your not refreshing your rst. Sorry if its a bit off as I'm tired and getting ready to call it a night.
VB Code:
Private Sub CommandButton3_Click()
Dim con As ADODB.Connection
Set con = New ADODB.Connection
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\exercise.mdb"
If Not TypeName(rst) = "Nothing" Then
'something
If rst.State = adStateOpen Then
'open
rst.Close
Set rst = Execute_SQL_ReturnRecordSet
Else
'closed
Set rst = Execute_SQL_ReturnRecordSet
End If
Else
'nothing
Set rst = Execute_SQL_ReturnRecordSet
End If
TextBox3.Text = rst.Fields("Qty")
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Jan 14th, 2006, 04:45 AM
#22
Thread Starter
Addicted Member
Re: [RESOLVED] How to set current date..??
Hi,
That all right..thanks very much anyway...But, when those codes run, then it has a "compile error : Argument not optional" when at go to this part "Set rst = Execute_SQL_ReturnRecordSet".....
Jan 14th, 2006, 09:30 AM
#23
Re: [RESOLVED] How to set current date..??
Oh, sorry. You need to pass the arguments to your function. I wasnt too familiar with your funciton.
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Jan 14th, 2006, 01:24 PM
#24
Re: [RESOLVED] How to set current date..??
Ok, I think this should do it. I was just going by your examples.
VB Code:
Private Sub CommandButton3_Click()
Dim con As ADODB.Connection
Set con = New ADODB.Connection
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\exercise.mdb"
If Not TypeName(rst) = "Nothing" Then
'something
If rst.State = adStateOpen Then
'open
rst.Close
Set rst = Execute_SQL_ReturnRecordSet("Select * from Item", False, "C:\exercise.mdb")
Else
'closed
Set rst = Execute_SQL_ReturnRecordSet("Select * from Item", False, "C:\exercise.mdb")
End If
Else
'nothing
Set rst = Execute_SQL_ReturnRecordSet("Select * from Item", False, "C:\exercise.mdb")
End If
TextBox3.Text = rst.Fields("Qty")
End Sub
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Jan 14th, 2006, 01:28 PM
#25
Thread Starter
Addicted Member
Re: [RESOLVED] How to set current date..??
Hi,
Sorry for that...but why NOW is getting worst....when I click "Check Current Stock", it always show the result "14"....
and the worst is..when I click "Add Stock" button...before, it runs well without errors, now it has errors:
VB Code:
Private Sub cmdAddStock_Click()
Dim con As ADODB.Connection
Set con = New ADODB.Connection
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" _
& "c:\exercise.mdb"
'update the data
Dim strSQL As String
strSQL = "UPDATE item " _
& " SET Qty = Qty + " & TextBox5.Text _
& " WHERE Item_Code = " & Trim$(cmb_item)
con.Execute strSQL
MsgBox "Your stock has been updated.", , "Update Stock Success"
TextBox3.Text = rst.Fields("Qty")
Application.ScreenRefresh
End Sub
and "con.Execute strSQL was yellow highlighted and errors: Syntax error (missing operator) in query expression 'Qty +'..???
Last edited by zach007; Jan 14th, 2006 at 01:31 PM .
Jan 14th, 2006, 01:31 PM
#26
Re: [RESOLVED] How to set current date..??
Probably because of the sql querystring. Not sure what your needing but this requeries the table and reloads the rst.
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Jan 14th, 2006, 02:09 PM
#27
Thread Starter
Addicted Member
Re: [RESOLVED] How to set current date..??
Hi,
It works for "Add Stock" button..that my mistakes...I forgot to put something there...BUT with "Check Current Stock" button, I really have no idea what is going on...it suppose to show current updated stock...BUT it keep show "14" which is the first row qty on the Item table...would you please have a look at my form and click it on "Check Current Stock" please...???...please....???....or if you are tired, you could check it tomorrow...I really stack......have you still got my file...????
I really need your help...
Thanks a lot....
Jan 14th, 2006, 02:33 PM
#28
Re: [RESOLVED] How to set current date..??
14 would be the first record. Whats its supposed to show?
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Jan 14th, 2006, 09:44 PM
#29
Thread Starter
Addicted Member
Re: [RESOLVED] How to set current date..??
It suppose to show on selected Item_code, then it will show its "Qty".....i.e. If I select Item_Code number 3, then it will show its qty....please help me for this code....
Last edited by zach007; Jan 14th, 2006 at 11:29 PM .
Jan 14th, 2006, 11:32 PM
#30
Re: [RESOLVED] How to set current date..??
Ok, then you will want to just move the recordset position to that record where the Item_Code matches the current Item_Code in the selected row on the form. You can do it with a loop and an rst.MoveNext with the test for match after that.
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Jan 15th, 2006, 12:06 AM
#31
Thread Starter
Addicted Member
Re: [RESOLVED] How to set current date..??
Hi,
I tried many times...but still did not works...this is my last codes for "Check Current Stock":
VB Code:
Dim con As ADODB.Connection
Set con = New ADODB.Connection
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\exercise.mdb"
Dim x As Integer
Dim ItemCodes(10)
For x = 1 To rst.RecordCount
ItemCodes(x - 1) = rst.Fields("Item_Code").Value
Debug.Print rst.Fields("Item_Code").Value & " " & _
rst.Fields("Description").Value
If Not TypeName(rst) = "Nothing" Then
'something
If rst.State = adStateOpen Then
'open
rst.Close
Set rst = Execute_SQL_ReturnRecordSet("Select * from Item", False, "C:\exercise.mdb")
Else
'closed
Set rst = Execute_SQL_ReturnRecordSet("Select * from Item", False, "C:\exercise.mdb")
End If
Else
'nothing
Set rst = Execute_SQL_ReturnRecordSet("Select * from Item", False, "C:\exercise.mdb")
End If
TextBox3.Text = rst.Fields("Qty")
rst.MoveNext
Next
Could you please fix my code please....????...Because I dont know what should I do anymore....
Thank you so much....
Jan 15th, 2006, 12:25 AM
#32
Re: [RESOLVED] How to set current date..??
No, you cant just do a .MoveNext without evaluating which record the recordset is on.
VB Code:
rst.MoveFirst
Do While rst.EOF = False
If UserForm1.txtQty.Text = rst.Fields("Item_Code").Value Then
Exit Do
End f
rst.MoveNext
Loop
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Jan 15th, 2006, 01:32 AM
#33
Re: [RESOLVED] How to set current date..??
Step through the code and see if your values are what you should be getting. Press F8 to step through the code after you place a breakpoint on Command3_Click and click the button.
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Jan 15th, 2006, 01:37 AM
#34
Thread Starter
Addicted Member
Re: [RESOLVED] How to set current date..??
Hi,
I did this codes and follow your codes...but still error:
VB Code:
Private Sub CommandButton3_Click()
Dim con As ADODB.Connection
Set con = New ADODB.Connection
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\exercise.mdb"
rst.MoveFirst
Do While rst.EOF = False
If UserForm1.txtqty.Text = rst.Fields("Item_Code").Value Then
Exit Do
End If
rst.MoveNext
Loop
TextBox3.Text = rst.Fields("Qty")
Application.ScreenRefresh
End Sub
and "TextBox3.Text = rst.Fields("Qty")" was in yellow highlighted...and error message like this: Run Time Error '3021' Either BOF is TRUE, or the current record has been deleted. Requested operation requires a current records.
Would you please correcr my codes...????..
Thank you so much....
Jan 15th, 2006, 02:10 AM
#35
Re: [RESOLVED] How to set current date..??
I dont see where your opening your recordset rst? I had it in the code I posted. This is why your probably getting the 3021 error.
VB Code:
Set rst = Execute_SQL_ReturnRecordSet("Select * from Item", False, "C:\exercise.mdb")
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Jan 15th, 2006, 02:43 AM
#36
Thread Starter
Addicted Member
Re: [RESOLVED] How to set current date..??
Hi,
I did this codes, but still errors:
VB Code:
Private Sub CommandButton3_Click()
Dim con As ADODB.Connection
Set con = New ADODB.Connection
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\exercise.mdb"
Set rst = Execute_SQL_ReturnRecordSet("Select * from Item", False, "C:\exercise.mdb")
rst.MoveFirst
Do While rst.EOF = False
If UserForm1.txtqty.Text = rst.Fields("Item_Code").Value Then
Exit Do
End If
rst.MoveNext
Loop
TextBox3.Text = rst.Fields("Qty")
Application.ScreenRefresh
End Sub
When I select item no 1, then when I press "Check Current Stock" it show its Qty...BUT, when I select other item numbers, let say item code number 3 it still show the Qty for item number 1...???....
Jan 15th, 2006, 02:49 AM
#37
Re: [RESOLVED] How to set current date..??
My mistake. We are not comparing the correct fields. We need to cpmpare the Item_Code field with whatever control holds that value on the userform.
VB/Office Guru™ (AKA: Gangsta Yoda ™ ® )
I dont answer coding questions via PM. Please post a thread in the appropriate forum.
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it!
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6
Jan 15th, 2006, 03:18 AM
#38
Thread Starter
Addicted Member
Re: [RESOLVED] How to set current date..??
Could you please show me the code please..???..Because I really have no idea how to do that...
Thanks very much....
Jan 16th, 2006, 09:37 PM
#39
Thread Starter
Addicted Member
Re: [RESOLVED] How to set current date..??
Please help me for this codes...?????
Jan 17th, 2006, 08:46 PM
#40
Thread Starter
Addicted Member
Re: [RESOLVED] How to set current date..??
Dear Experts,
Has anyone could help me please for these code?
VB Code:
Private Sub CommandButton3_Click()
Dim con As ADODB.Connection
Set con = New ADODB.Connection
con.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=c:\exercise.mdb"
Set rst = Execute_SQL_ReturnRecordSet("Select * from Item", False, "C:\exercise.mdb")
rst.MoveFirst
Do While rst.EOF = False
If UserForm1.txtqty.Text = rst.Fields("Item_Code").Value Then
Exit Do
End If
rst.MoveNext
Loop
TextBox3.Text = rst.Fields("Qty")
Application.ScreenRefresh
End Sub
When I select item no 1, then when I press "Check Current Stock" it show its Qty...BUT, when I select other item numbers, let say item code number 3 it still show the Qty for item number 1...???....
Please help with code corrections...
Thank you so much...
Posting Permissions
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
Forum Rules
Click Here to Expand Forum to Full Width