hi thnx all for the help last time.
nw i hav another prob.
i am developing an application for the doctors n wanna store all the patients records.i am using an access database.nw my problem is tat the register no. tat is the identity of the patient has to be calculated by the application itself n it is also the primary key in the table. nw the prob is tat the doctor wants it new every month like suppose todays first of the month n the reg. no of the first patient will be 1_7/2009 n the next will be 2_7/2009 n will continnue till the last day of the month bt when the next month comes up it shld again start with 1 i.e 1_8/2009 n so on. plz help

9 Years
Discussion Span
Last Post by iCreator

for now i hav done it tis way tat i hav retrived the default id in the table and appended the month n year to it. bt the doc wants it tat way.
sql = "Select id from Table1"

'da = New OleDb.OleDbDataAdapter(sql, con)

'da.Fill(ds, "example")
'For j As Integer = 0 To ds.Tables("example").Rows.Count - 1
' TextBox1.Text = ds.Tables("example").Rows(j).Item(0)
Dim adate As String
adate = MonthCalendar1.TodayDate.Month & "/" & MonthCalendar1.TodayDate.Year
dim i as integer
reg = i & "_" & adate
TextBox1.Text = reg

this work f9 bt i dont get the desired result
plz help


Hi Sana.khatib20,

you first change the topic of your thread... so it could be easy for others who search for the similar problem or for those who view the forum or ur thread for the first tym cud get an idea of your problem...


i want code to calculate the reg_no automatically.it shld be self incrementing for every new patient and shld start from 1 every month and shld continue for the whole month.
plzz help


extract the last record from the database
extract the id part(the part tht is left after u separate the date part)
u can use substring method for this
then increment it and append the date


Hi Sana.khatib20!

I think your requirement is like such,
Reg_Id = Incremental_Id + Date_Id

To get Incremental_Id you must read no of records in that month.
e.g. select count (*) from example where month(date) = month(now())

And you know how to get Date_Id.:)


This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.