473,383 Members | 1,980 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,383 software developers and data experts.

help for find first date

1
Hello
Iam trying to find a date from table "taqrir" matching to date in unbound text box in form by this code as below:
Expand|Select|Wrap|Line Numbers
  1.  
  2. Private Sub cmdAppend_Click()
  3. Dim dbs As Database
  4. Dim rs As Recordset
  5. If IsNull(Me.M_Date) Then
  6. MsgBox "Please Enter desire Monday date first!"
  7. Else
  8. Set dbs = CurrentDb
  9. Set rs = dbs.OpenRecordset("Taqrir", dbOpenDynaset)
  10.         rs.FindFirst "[Date]=#" & Me.M_Date & "#"
  11.  
  12.         If rs.NoMatch Then
  13.  
  14.  
  15.  
  16. DoCmd.RunSQL "INSERT INTO Taqrir ( Std, darajah, subid, period, dayid, srno )SELECT [darajah] & [div] & [sex] AS Std, [jadwal table].darajah, [jadwal table].subid, [jadwal table].period, [jadwal table].dayid, [jadwal table].srno FROM [jadwal table]WHERE ((([jadwal table].darajah)>0));"
  17. DoCmd.RunSQL "PARAMETERS [Forms]![frm_main]![M_Date] DateTime;UPDATE Taqrir SET Taqrir.[Date] = IIf([dayid]=1,[Forms]![frm_main]![M_Date],[Forms]![frm_main]![M_Date]+([dayid]-1))WHERE (((Taqrir.Date) Is Null));"
  18.  
  19.     MsgBox "Data Appended successfully!"
  20.  
  21.     Else
  22.             'Display the found record in the form.
  23.            MsgBox "Data already appended for this date! Get print outs of them from below. "
  24.         End If
  25.         Set rs = Nothing
  26.     End If
  27. End Sub
  28.  
I have matching date in taqrir table, but instead i am getting No Match results. Please help to resolve this issue.

I wil be too grateful of u.

Mustafa Shfaqat husain
Nov 24 '07 #1
1 3929
puppydogbuddy
1,923 Expert 1GB
Hello
Iam trying to find a date from table "taqrir" matching to date in unbound text box in form by this code as below:

Private Sub cmdAppend_Click()
Dim dbs As Database
Dim rs As Recordset
If IsNull(Me.M_Date) Then
MsgBox "Please Enter desire Monday date first!"
Else
Set dbs = CurrentDb
Set rs = dbs.OpenRecordset("Taqrir", dbOpenDynaset)
rs.FindFirst "[Date]=#" & Me.M_Date & "#"

If rs.NoMatch Then



DoCmd.RunSQL "INSERT INTO Taqrir ( Std, darajah, subid, period, dayid, srno )SELECT [darajah] & [div] & [sex] AS Std, [jadwal table].darajah, [jadwal table].subid, [jadwal table].period, [jadwal table].dayid, [jadwal table].srno FROM [jadwal table]WHERE ((([jadwal table].darajah)>0));"
DoCmd.RunSQL "PARAMETERS [Forms]![frm_main]![M_Date] DateTime;UPDATE Taqrir SET Taqrir.[Date] = IIf([dayid]=1,[Forms]![frm_main]![M_Date],[Forms]![frm_main]![M_Date]+([dayid]-1))WHERE (((Taqrir.Date) Is Null));"

MsgBox "Data Appended successfully!"

Else
'Display the found record in the form.
MsgBox "Data already appended for this date! Get print outs of them from below. "
End If
Set rs = Nothing
End If
End Sub


I have matching date in taqrir table, but instead i am getting No Match results. Please help to resolve this issue.

I wil be too grateful of u.

Mustafa Shfaqat husain
Try this and see if it helps. Access date data types have date and time components. Using the DateValue function will extract just the date component. I am not positive, but I don't think you need date delimiter # when DateValue used, but try it both ways:

rs.FindFirst "[Date]= " & DateValue(Me.M_Date)

if the above does not work, then try this with date delimiter.
rs.FindFirst "[Date]=#" & DateValue(Me.M_Date) & "#"
Nov 24 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Rainmaker | last post by:
Greetings, I have not been able to find the documentation that will allow me to insert php code inside the html code in the $message block in the mail() function. Using the example in the help...
5
by: Got2Go | last post by:
Hello Group, I have a table that has 3 columns: ID (int), datetime, Value(varchar) ID = ID for the SNMP device datetime = time record was added value = value added for that device. This...
3
by: John Fitzgerald | last post by:
Hi, I have the following two tables: 1. Client Table ID - Primary Key 2. Enrollment Table EnrollID - Primary Key ClientID - Foreign Key Enroll Date
5
by: Mahesha | last post by:
Hello, I need help in replacing one string pattern with another. Ex: I have a financial security expression like log(T 3.25 6/24/2004)/sqrt(T 4.5 6/19/2002) Here "T 3.25 6/24/2004" is a...
6
by: James Radke | last post by:
Hello, I have a multithreaded windows NT service application (vb.net 2003) that I am working on (my first one), which reads a message queue and creates multiple threads to perform the processing...
17
by: Timothy.Rybak | last post by:
Hello all, This is my first attempt at an application, so kid gloves are appreciated. I need to make a very simple form that only has a few elements. One is TraceCode - a text field that is...
6
by: D | last post by:
Hello all...I have an issue with one of my java script functions that I'm hoping someone can easily help with. I have a web based application that we use to create/sign up for overtime. When we...
0
by: georges the man | last post by:
The purpose: • Sorting and Searching • Numerical Analysis Design Specification You are to write a program called “StockAnalyser”. Your program will read a text file that contains historical...
0
by: gunimpi | last post by:
http://www.vbforums.com/showthread.php?p=2745431#post2745431 ******************************************************** VB6 OR VBA & Webbrowser DOM Tiny $50 Mini Project Programmer help wanted...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.