Click here to Skip to main content
15,887,135 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: How to use ArrayList? Pin
codemunkeh27-Jul-07 16:28
codemunkeh27-Jul-07 16:28 
QuestionHelp with dll Pin
Bad Programmer27-Jul-07 9:46
Bad Programmer27-Jul-07 9:46 
AnswerRe: Help with dll Pin
Christian Graus27-Jul-07 11:02
protectorChristian Graus27-Jul-07 11:02 
GeneralRe: Help with dll Pin
Bad Programmer27-Jul-07 11:18
Bad Programmer27-Jul-07 11:18 
GeneralRe: Help with dll Pin
Dave Kreskowiak27-Jul-07 11:25
mveDave Kreskowiak27-Jul-07 11:25 
QuestionRe: Help with dll Pin
Bad Programmer30-Jul-07 8:51
Bad Programmer30-Jul-07 8:51 
AnswerRe: Help with dll Pin
Dave Kreskowiak30-Jul-07 12:58
mveDave Kreskowiak30-Jul-07 12:58 
QuestionTrying to find the highest number in a field.... Pin
CCG327-Jul-07 9:14
CCG327-Jul-07 9:14 
Hello everyone,

I am running VB.Net 2005 looking at an Access 2003 database.

I have a task that I am trying to get my head around and I need some help with. I have to read through a table and get the highest number from a certain field. I am kind of doing this already but I am doing a Count, I count the number of records returned from a filter/SQL statement and then using that amount, I add 1 to it and that is my Encounter number. But now I need change this process because it wasn't working out so great. Can someone look at this code and explain how I can change it to accomplish my task? Or point me to an article that will show me how to do this?

What you will see is that I am filtering out based on values in 2 fields, then counting the records returned. Instead I need run this filter/sql statement, but then look at a 3rd field in the table called PatSurgEnNo. and of the records returned with the filter/sql statement of the first 2 fields (MR number and VisitDate), I need to find the highest number in the PatSurgEnNo fields, so I can add 1 to it and that will become my new/current Encounter number.

Thanks in advance for any help that you can give!

Code I have now:

Dim PatSurgDate As String

MR = Me.txtMRNo.Text
PatSurgDate = Me.cbobxVisitDate.Text.ToString()

'Set Encounter to 0, count how many encounters for this date there are
' then add one to the encounter before creating a new entry
PatSurgEncounter = 0
Dim Count As Integer = 0
Using Connection As New OleDbConnection _
("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & DBPath)


Dim cmd As OleDbCommand = New OleDbCommand _
("Select Count(PatSurgAutoNo) as existingrecords from [Pat19PatSurg] where [PatSurgMRNo]=? and [PatSurgDate]=?", _
Connection)

cmd.Parameters.AddWithValue("@PatSurgMRNo", MR)
cmd.Parameters.AddWithValue("@PatSurgDate", PatSurgDate)
Connection.Open()
Count = cmd.ExecuteScalar

End Using

If Count >= 0 Then

'set new SurgEncounterNumber
PatSurgEncounter = Count + 1

Return

End If

AnswerRe: Trying to find the highest number in a field.... Pin
Christian Graus27-Jul-07 9:43
protectorChristian Graus27-Jul-07 9:43 
AnswerRe: Trying to find the highest number in a field.... Pin
Paul Conrad27-Jul-07 10:01
professionalPaul Conrad27-Jul-07 10:01 
AnswerRe: Trying to find the highest number in a field.... Pin
Naji El Kotob27-Jul-07 11:20
Naji El Kotob27-Jul-07 11:20 
QuestionError Message Pin
jds120727-Jul-07 7:31
jds120727-Jul-07 7:31 
AnswerRe: Error Message Pin
codemunkeh27-Jul-07 7:49
codemunkeh27-Jul-07 7:49 
AnswerRe: Error Message Pin
Paul Conrad27-Jul-07 8:28
professionalPaul Conrad27-Jul-07 8:28 
AnswerRe: Error Message Pin
Johan Hakkesteegt31-Jul-07 22:26
Johan Hakkesteegt31-Jul-07 22:26 
QuestionImporting data into Sharepoint document libraries Pin
Potso27-Jul-07 7:19
Potso27-Jul-07 7:19 
QuestionHELP PLEASE. BASIC EXCEL TASKS Pin
frankiebaby227-Jul-07 6:07
frankiebaby227-Jul-07 6:07 
AnswerRe: HELP PLEASE. BASIC EXCEL TASKS Pin
frankiebaby227-Jul-07 8:57
frankiebaby227-Jul-07 8:57 
Questionprint the richtextbox text Pin
eyes200727-Jul-07 5:03
eyes200727-Jul-07 5:03 
AnswerRe: print the richtextbox text Pin
Paul Conrad29-Jul-07 6:16
professionalPaul Conrad29-Jul-07 6:16 
QuestionCRC 16 Pin
Cory Kimble27-Jul-07 3:46
Cory Kimble27-Jul-07 3:46 
AnswerRe: CRC 16 Pin
kubben27-Jul-07 5:24
kubben27-Jul-07 5:24 
GeneralRe: CRC 16 Pin
Cory Kimble27-Jul-07 6:43
Cory Kimble27-Jul-07 6:43 
GeneralRe: CRC 16 Pin
Luc Pattyn27-Jul-07 13:32
sitebuilderLuc Pattyn27-Jul-07 13:32 
GeneralRe: CRC 16 Pin
Cory Kimble30-Jul-07 7:03
Cory Kimble30-Jul-07 7:03 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.