ChrisPadgham 113 Posting Whiz

you don't need to disable the header. In your code before line two put some code like

if e.RowIndex < 0 then
  msgbox "Please double click on the cell you are interested in"
  exit sub
end if

it is better to provide instructive feedback to your user than simply disable things.

ChrisPadgham 113 Posting Whiz

WIA is your best bet if your scanner drivers support it. Otherwise you will need to use TWAIN. There is a product called EZITWAIN which I have used at a client where WIA did not work.

Begginnerdev commented: Thanks for the input! +4
ChrisPadgham 113 Posting Whiz

It is hard to believe that you will be able to write something that will search faster than word can if you leave it in word format. If you load the data into a database first then searching on the database will be much faster.

ChrisPadgham 113 Posting Whiz

you can use an SQL INSERT statement eg

"INSERT INTO mytable (newname, newamount) VALUES('Fred',25);"

ChrisPadgham 113 Posting Whiz

.sort is not support by all ADO, perhaps it is simpler to put the sort in the SQL

stSQL = "SELECT [Barcode ID] FROM Barcode ORDER BY [Barcode ID]"

ChrisPadgham 113 Posting Whiz

try this


Data1.Recordset.Sort "[Barcode ID] DESC"

ChrisPadgham 113 Posting Whiz

the square brackets should be around the fieldname

Data1.Recordset.Sort ("[Barcode ID] DESC")
Do Until Data1.Recordset.EOF    
   HE = Data1.Recordset("[Barcode ID]")    
   MsgBox HE    
   Data1.Recordset.MoveNext
Loop
ChrisPadgham 113 Posting Whiz

the filename of the database you wish to backup, eg


FSO.CopyFile App.Path & "\MyDatabase.mdb", sDBfn

you need to need to ensure that the database is not open at the time. The easiest is to start your VB program in sub Main and backup there before any links to the database have been created.

ChrisPadgham 113 Posting Whiz

for a start shouldn't it be DESC not DEC and

if you are talking to MS SQL Barcode ID cannot have a space in it, eg BarcodeId
if you are talking to MSAccess then it needs to be inclosed in square brackets [Barcode ID]

ChrisPadgham 113 Posting Whiz

As Waltp says, if you want to replace the whole contents of the text box or if you only want to replace a substring in the text box

text1.text = replace(text1.text,"original","new)

Replace function documented here

ChrisPadgham 113 Posting Whiz

isn't sDBTmpfn incorrect, it should be the file name of the database you are trying to back up.

and the MoveFile should probably be a CopyFile

ChrisPadgham 113 Posting Whiz

so what is the database and how are you trying to back it up

ChrisPadgham 113 Posting Whiz

if you have more than one type you may be better with a user defined type

Public Type UserDetails
    MyName As String
    BackupName As String
    CurrId as Integer
End Type

dim Userlist(99) as UserDetails
ChrisPadgham 113 Posting Whiz

Are you referring to a FileOpen dialog box

ChrisPadgham 113 Posting Whiz

Rather than calculating the Duration possibly

appointmentTime = starttime
do until appointmentTime >= endtime
    cmbTime.Items.Add(appointmentTime.ToString)
    appointmentTime = appointmentTime.AddMinutes(AppointmentDuration)
loop

note that if Appointment duration does not divide evenly the last appointment will overrun the end time. If this is not acceptable you will need to add the AppointmentDuration to the endTime in the until clause

ChrisPadgham 113 Posting Whiz
dim TwoDArray(10,10) as Int16
ChrisPadgham 113 Posting Whiz

it looks very much like an third party library, go to add-ins menu and click Add-in Manager, see if you can find something that looks like this to add to the project.

ChrisPadgham 113 Posting Whiz

is it not simpler to us the isnumeric function

ChrisPadgham 113 Posting Whiz

The most robust way is to import the data into a staging table, each column in the staging table is text 255.

Do your validation there before inserting the data into the product table.

Alternatively you could open the excel spreadsheet as an embedded object and work through it cell by cell validating as you go.

ChrisPadgham 113 Posting Whiz

Have you tried stepping through it in debugger, set a break point at the spot it is adding the "0" on the front and check out what is wrong with your logic

or

instead of

f &= ZeroPad(line, 7) & vbCrLf

use the format function

f &= line.format("0000000")
ChrisPadgham 113 Posting Whiz

Make it the Primary Key then set it to autoincrement and the database will assign an id for you, no need to worry about it in the code.

ChrisPadgham 113 Posting Whiz

I know this is not what you asked but if you just want to check if it is a valid date then you can use the isdate() function.

ChrisPadgham 113 Posting Whiz

hmmm not really fully normalised though. How many Min/Max power combinations could you have? not that many I would have thought.

If you are going down this path, why would you not just store the price rather than the Bracket id in the Wiring table. then you would not need to join the other table at all

BitBlt commented: Very true, good point. +8
ChrisPadgham 113 Posting Whiz

Can a purchase order have more than one product on it.

if not, put a foreign key (ContractId) in the tblPurchaseOrder table.
if so, put a foreign key (ContractId) in the tblPurchaseOrderLine table.

ChrisPadgham 113 Posting Whiz

AND will only return one record if there is only one record matching the where clause. If you have multiple rows that match you will get multiple rows back, for example if your table holds the following data

FLD1 | FLD2 | FLD3
XXX | 111 | A
XXX | 111 | B
XXX | 222 | B

and your where clause is

WHERE FLD1='XXX' AND FLD2='111'

then you will have two rows returned

ChrisPadgham 113 Posting Whiz

Yes since incident has a many-to-one relationship with student you need a separate table to hold incidents (probably called something like "Incident"). Personally I prefer an autonumber field as a primary key of the Incident table, say IncidentNo.

StudentId should be included in the Incident table as a foreign key.

ChrisPadgham 113 Posting Whiz

no it took ages for me to work out what the problem was.

ChrisPadgham 113 Posting Whiz

check out the string.replace method. eg

newstring = imagem_box.Text.replace("\","\\")

I haven't tested it, (don't have a .net environment with me at the moment)

ChrisPadgham 113 Posting Whiz

I had a similar problem coding in MS Access you might like to try using two slashes on the input i.e.

f:\\pap\\siteimages\\curso\\drum.jpg

you can put it in manually first to test, then if that is the problem, change your code to insert the second slash programmatically

ChrisPadgham 113 Posting Whiz

I presume the image path is stored in the field imagem_box.Text

are you saying that when you execute the insert command the data in column imagem_curso does not contain the forward slashes

ChrisPadgham 113 Posting Whiz

check out the datediff function I think you will find it does what you need

ChrisPadgham 113 Posting Whiz

Tuition = myCommand.ExecuteScalar.ToString

ChrisPadgham 113 Posting Whiz

I think the problem is more that the spreadsheet is treating the data as numbers if you altered the formating in the spreadsheet to treat it as text it may solve your problem

ChrisPadgham 113 Posting Whiz

Presuming you hold year first enrolled in the Student table you are best to use a calculated field in a view that concatenates these to fields

YearEnrolled & '-' & StudentId AS StudentNo

ChrisPadgham 113 Posting Whiz

Use the Alignment property of the text box to specify left or right alignment

ChrisPadgham 113 Posting Whiz

I presume you are populating from the object MyRecSet1. If you have populated this recordset why not just check the RecordCount property to see if there are any rows returned and disable the remove button if there are no rows.

ChrisPadgham 113 Posting Whiz

one other thing. I think you will need to use

Randomize

at the top of your program to get a truely random number, other wise you get the same sequence of numbers each time you run the program

ChrisPadgham 113 Posting Whiz

I think your first effort looks OK, you just need and Exit Sub after line 6.

ChrisPadgham 113 Posting Whiz

The difficulty is that count() works against summarising existing rows in a table. By definition a count of 0 means that no rows exist so nothing will appear. How would SQL know what the missing values were. To address the problem you will need to set up a reference table with all the valid values in it and do an outer join against the table with the data in it.

ChrisPadgham 113 Posting Whiz

In the Unload event of the form set the valve to Close then use End to terminate the program.

ChrisPadgham 113 Posting Whiz

The former is a better design however Profile should really be Person and you don't need two teacher tables

Person
PersonId (pk)
LastName
FirstName
Tel

Teacher
TeacherId (Pk)
PersonId (Fk)
TeacherQuals

Student
StudentId (Pk)
PersonId (fk)

chandimak commented: Well explained. +0
ChrisPadgham 113 Posting Whiz

I am not sure why you are doing the filtering in a second step

Private Sub OpenSeizureForm() 
   dim stFilter as String
   If Me.NewRecord Then  
      'Open form in dataentry mode
      DoCmd.OpenForm "Seizures", acNormal, , , acFormAdd, acWindowNormal, Me.incidentNum & "&Episode"

 Else 
      ' open and filter form
      stFilter = "[IncidentNum] = '" & Me.[incidentNum] & "' And [SourceTable] = 'Episode'"
      DoCmd.OpenForm "Seizures", acNormal, ,  stFilter, , acWindowNormal, Me.incidentNum & "&Episode"

End If
End Sub

Private Sub Form_Load
    Dim argSplit() As String
    argSplit = Split(CStr(Me.OpenArgs), "&")
    
    'Set the DefaultValue which means new records will have these values 
    Me.txtIncidentNum.DefaultValue = CStr(argSplit(0))
    Me.sourceTable.DefaultValue = CStr(argSplit(1))
End Sub
ChrisPadgham 113 Posting Whiz

If you change the way you are thinking about the problem. Lets say you can only fit 5 text boxes in the frame. Then you only have 5 text boxes. As the user scrolls up or down simply change the captions and contents of the text boxes in the frame. YOu will need to keep track of which data is currently being displayed but you can do this via the captions.

ChrisPadgham 113 Posting Whiz

If you don't want to reflect the character int the textbox set the KeyCode variable to 0 in the form_keydown event

ChrisPadgham 113 Posting Whiz

Setting the KeyPreview property of the Form will enable the Form to process the KeyDown event before any controls on the form do.

ChrisPadgham 113 Posting Whiz

If you are using the SQL, you may like to investigate using the RecordsAffected property to determine whether the row was deleted and inform the user accordingly.

ChrisPadgham 113 Posting Whiz

"N" & format$(val(right$(SerialNo,4))+1,"0000")

ChrisPadgham 113 Posting Whiz
ChrisPadgham 113 Posting Whiz

Find code below however this may not be the best way of achieving what you want.

In the LostFocus event, you can check if they have entered a valid date as follows

if not isdate(text1.text) then
msgbox "Please enter a valid date"
text1.setfocus
text1.selstart = 0
text1.sellength = len(text1.text)
end if

however if you want to stick to your original here is the code.

Private Sub Text1_KeyPress(KeyAscii As Integer)

Keyascii = CheckChar(KeyAscii)
end sub

public function CheckChar(KeyAscii as integer) as integer
Dim ch As String 
CheckChar = KeyAscii
ch = Chr$(KeyAscii)
If Not ( _(ch >= "0" And ch <= "9") Or _KeyAscii = 8 Or _KeyAscii = 13 Or _KeyAscii = 84 Or _KeyAscii = 116 Or _KeyAscii = 47) Then ' Cancel the character.
CheckChar = 0
End If 
If KeyAscii = 116 Or KeyAscii = 84 Then
CheckChar= 0
End If
end function
ChrisPadgham 113 Posting Whiz

Replace first line with

Dim arrWhite(rs.Fields.Count - 1) As Double