vb5prgrmr 143 Posting Virtuoso

Also, on form select your adodc1 control, press F1, goto properties on the help file>select Recordset Property Ado Data Control>and read what you may have to do to get the above to work.

Good Luck

vb5prgrmr 143 Posting Virtuoso
Private Sub cmdadd_Click()    
Adoaddlec.Recordset.AddNew
optftime.Value = False    
optptime.Value = False    
optict.Value = False    
optassessmentprogramme.Value = False    
optdbt.Value = False    
opttvet.Value = False    
optcarrerdev.Value = False    
optictinstruc.Value = False    
opteventsmanagement.Value = False    
opteduandtranng.Value = False    
optcnstrudsitemanagement.Value = False    
cboparish.Text = "Select Parish"     
Adoaddlec.Recordset.update
End Sub
vb5prgrmr 143 Posting Virtuoso

Well you are using a recordset object which is normally for retrieving records. Check either you connection object or you database object (if you have one) for the .execute method. i.e.

conn.execute sql3
vb5prgrmr 143 Posting Virtuoso
Private Sub cmdsave_Click()
Dim street As String
street = txtstreet.Text

If (txtlname.Text = "") Then
  MsgBox "Last Name is compulsory", vbExclamation + vbOKOnly, "Atmoic Inc"
  txtlname.SetFocus
  [b]Exit Sub[/B]
ElseIf (txtfname.Text = "") Then
  MsgBox "First Name is compulsory", vbExclamation + vbOKOnly, "Atmoic Inc"
  txtfname.SetFocus
  [b]Exit Sub[/B]
...

If any condition fails you need to exit the sub to allow the user to enter the information.

I also do not see a

Adoaddlec.Edit

anywhere

I would think that you would want to evaluate your controls PRIOR to updating/appending records to your database. Meaning, evaluate your controls first, then when you know that they all contain valid values do your .Edit, .Field = value, .Update.

Good Luck

vb5prgrmr 143 Posting Virtuoso
If optict.Value = True Then
  Adoaddlec.Recordset.Fields("department") = "1"
...
vb5prgrmr 143 Posting Virtuoso

I am guessing you are using access as your database, Goto the design of the table and check each field to see if down at the bottom the required is set to yes.

vb5prgrmr 143 Posting Virtuoso

Do the reverse of what you are doing...

vb5prgrmr 143 Posting Virtuoso

Please read my post more carefull and if you need help type in zorder, highlight it, and press F1 from inside vb.

vb5prgrmr 143 Posting Virtuoso

inserting into a table should not be a problem as long as you add values for each field that has the required arguement set to yes. However, you may be able to get around the need for this by specifying a default value.

Good Luck

vb5prgrmr 143 Posting Virtuoso

Are you using .NET? if so you are in wrong forum...
but this works for me

Option Explicit

Private Sub Form_Load()
Dim S As String
S = "string1" & vbNewLine & "string2" & vbNewLine & "string3" & vbNewLine & "string4" & vbNewLine
S = S & "string5" & vbNewLine & "string6" & vbNewLine & "string7" & vbNewLine & "string8"
Text1.Text = S
End Sub

Private Sub Command1_Click()
Text1.Text = StrConv(Text1.Text, vbProperCase)
End Sub
vb5prgrmr 143 Posting Virtuoso

How about one line...

Option Explicit

Private Sub Form_Load()
Dim S As String
S = "string1 string2 string3 string4 string5 string6 string7"

S = StrConv(S, vbProperCase)
Debug.Print S

End Sub

Good Luck

vb5prgrmr 143 Posting Virtuoso

Insert into tablename (field1, field2) values (value1, value2)

Okay, the above is the basic psudo code design of your insert statement. Now where it says field1 that represents your First Name field and you are getting the error that says it cannot find the first name field. So, one of the easiest ways to figure this out is to open the table in design view, find the first name field, highlight it, copy the field name, and then paste it into your code.

The reason for these steps is I am betting that the first name field might be named differently like first_name or as I sometimes like to do FName. So make sure that you have the correct spelling for your table name and field names. Then check to make sure they are of the correct data types.

Good Luck

vb5prgrmr 143 Posting Virtuoso

I could be wrong, but, I believe windows cycles through the zorder to shut programs down. A way to test this is to have several programs or your design running. Tile them in the order you want on the desktop and when they are told by windows to shut down they use something like gettickcount and save that information to a file. Then once you are restarted, check those files.

Good Luck

vb5prgrmr 143 Posting Virtuoso

HI v5prgrmr Dim mysql As String = "insert into Customer_tbl values('First Name','Last Name') values ('John','Unknown');"

Ahh... My bust. Dim mysql As String = "insert into Customer_tbl ('First Name','Last Name') values ('John','Unknown');" Remove that first values

vb5prgrmr 143 Posting Virtuoso

Image1.left=image1.left+10

vb5prgrmr 143 Posting Virtuoso

new project>add timer control (timer1), image control(image1)
give image1 an image to display>add code

Option Explicit

Dim Bomb1 As Boolean, Bomb1Animation As Boolean

Private Sub Form_Load()
Image1.Visible = False
Me.KeyPreview = True
Timer1.Interval = 10
Timer1.Enabled = True
End Sub

Private Sub Form_KeyPress(KeyAscii As Integer)

If KeyAscii = 88 Or KeyAscii = 120 Then 'x or X
  Bomb1 = True
End If

End Sub

Private Sub Timer1_Timer()

Timer1.Enabled = False

If Bomb1 = True Then
  If Bomb1Animation = True Then
    If Image1.Left + Image1.Width < 0 Then
      Bomb1Animation = False
      Bomb1 = False
    Else
      Image1.Left = Image1.Left - 50
      Me.Refresh
      Image1.Refresh
    End If
  Else
    Bomb1Animation = True
    Image1.Visible = True
    Image1.Left = Me.Width - 1
  End If
End If

Timer1.Enabled = True

End Sub

as you can see there is no error checking but this should work for you

Good Luck

vb5prgrmr 143 Posting Virtuoso

Yes, and yes.

Form1.Keypreview = true

in the timer you will need to check to see if the user actually pressed the key via a form level variable or two.

Then as you become more accustomed to VB check out the forms/pictureboxes graphical methods (line circle) and then move onto the API BitBlt.

Good Luck

vb5prgrmr 143 Posting Virtuoso

Access, SQL, MSDE, dBase, Fox Pro, Alpha5? What is your DBMS?

a simple generic way of pulling information based upon dates is as follows.

Select * from yourtable where yourdatefield >= somedate AND yourdatefield <= somedate

Then there is the between statement if your DBMS supports it

From VB press F1>GoTo index tab and type in Between...And operator>Click on example
code from example for access and the example northwind dababase

Sub SubQueryX()

   Dim dbs As Database, rst As Recordset

   ' Modify this line to include the path to Northwind
   ' on your computer.
   Set dbs = OpenDatabase("Northwind.mdb")
   
   ' List the name and contact of every customer 
   ' who placed an order in the second quarter of
   ' 1995.
   Set rst = dbs.OpenRecordset("SELECT ContactName," _
      & " CompanyName, ContactTitle, Phone" _
      & " FROM Customers" _
      & " WHERE CustomerID" _
      & " IN (SELECT CustomerID FROM Orders" _
      & " WHERE OrderDate Between #04/1/95#" _
      & " And #07/1/95#);")
   
   ' Populate the Recordset.
   rst.MoveLast
   
   ' Call EnumFields to print the contents of the 
   ' Recordset. Pass the Recordset object and desired
   ' field width.
   EnumFields rst, 25

   dbs.Close

End Sub

Good Luck

vb5prgrmr 143 Posting Virtuoso

update Details set NAME='" & txtName.Text & "' and DT_OF_BTH=#" & txtDOB.Text & "# and DT_OF_JOING=#" & txtDOJ.Text & "# and SALARY_ACC=" & txtAccountNo.Text & " and REMBSMNT_ACC=" & txtRmbr.Text & " and PHONE_NO=" & txtPhno.Text & " where PS_No=" & Trim(txtPSNo.Text)

I think that should do it

vb5prgrmr 143 Posting Virtuoso

The simplest way for a test, is to use a control that can contain a graphic and has a visable property like the picture box control or an image control. You will need at least a couple of these. Then use a timer or two (one would do) and within the timer you would either increment (left to right) or decrement (right to left) the left property of the control. Thus you have your animation.

Now that is one of the easiest ways to accomplish what you want but you will need to do a fair amount of coding to make it work correctly. From there, it only takes more code.

Good Luck

vb5prgrmr 143 Posting Virtuoso

see strongm's threading post (about halfway down) at http://www.tek-tips.com/viewthread.cfm?qid=519374

It can be adapted quite easily for what you want to do but I must warn you do not get too creative with threads in vb6. If you need any help please post again.

Good Luck

vb5prgrmr 143 Posting Virtuoso

Use the Format function

txtreceitno = Format(rs.fields("orno") + 1, "00000")

Good Luck

vb5prgrmr 143 Posting Virtuoso

Okay, then all you need is the last line of the readfile...

ReadFileReturnStringArray = Split(StringContents, vbNewLine)
vb5prgrmr 143 Posting Virtuoso

comment Unload Me in your code and i hope the rest wills tart working. use Me.Hide instead of unload Me.

I take it you did not read my post too well...

vb5prgrmr 143 Posting Virtuoso

Access does not like it when you pass up a string for a number field and that is what you are doing when you wrap your numbers with quotes.

vb5prgrmr 143 Posting Virtuoso

Couple of possibilities

Lets start with the date. Are you sure it is a properly formatted date?
What DBMS (Access, SQL, dBase)?
Each handle dates just a little bit differently. If you are using Access then go to the query analyzer, build your insert string there and see what characters it uses to wrap around the date field. Take that knowledge and apply it to your update string.

Now, onto salary. You are wrapping a number with single ticks ' so you are telling your database to update a number with a text string and it looks like you are doing the same for the other number fields in your statement.

Other worries:
I don't see any validation code, meaning are you sure the information that the use is entering is valid. i.e. the user is not trying to update the salary field with a string like "'Fifty thousand dollars and no cents'"

Good Luck

vb5prgrmr 143 Posting Virtuoso

Okay, right of the bat I can see a potential problem with your timer control and its sub procedure. Not knowing, as I only read the first few lines, what your timer interval is set at I can guess that it may be way too low causing a problem called reentrancy, which means that the first time the timer is called, if the code inside the timer does not complete before the timer is triggered again, then you have the same code starting to execute again. The second thing that I see wrong with the code inside the timer is that you try to unload the form but you do not stop the timer by setting its enable property to false or by setting its interval property to zero. Now you can do this in the form unload event but I don't see that code posted.

So here is what seems to be happening with your code. The form displays, the timer triggers, and lickity split the progress bar reads 100% and you unload the form. Problem is, the timer activates again thus reloading the form and starting the process all over again in an endless loop.

So how to fix this...

There are a couple of ways and what follows is just one.

First you could use a variable declared at form level...

Option Explicit

Dim TimerCounter As Integer

Then in your form load event you setup your timer and progress bar

Private …
vb5prgrmr 143 Posting Virtuoso

I found a method on how to terminate a program but it needs the exact program title for it to be terminated. Does it work on a full screen applications?

The code will have to be modified some with the use of the GetTopWindow and GetDesktopWindow API's and this is assuming that the game is the top window in the Z order but if you are clicking a button on your program then you will also need to send your program to the back of the Z order by either minimizing it or using SetWindowPos before you kill the program that is at the top of the Z order.

Good Luck

vb5prgrmr 143 Posting Virtuoso

search web for
terminating a process
or
end a program through code

There are many examples

Good Luck

vb5prgrmr 143 Posting Virtuoso

Why loop on input when you can read whole file in in one step?

Public Function ReadFileReturnStringArray(PathFileName As String) As String()

Dim FileNumb As Integer,  FileContents As String

'get a free file handle
FileNumb = FreeFile

'open file
Open PathFileName For Binary As #FileNumb

'retrieve its contents
FileContents = Input(FileLen(PathFileName), #FileNumb)

'close file to reclaim resources asap
Close #FileNumb

ReadFileReturnStringArray = Split(FileContents, vbNewLine)

End Function

Then from calling proc

Public Sub CallingSub()

Dim MyArray() As String, UpperLimitOfArray As Integer, ForLoopCounter As Integer
Dim MySearchString As String, FoundSearchStringPosition As Integer

MyArray = ReadFileReturnStringArray("C:\YourPath\YourFile.Extension")

UpperLimitOfArray = Ubound(MyArray)

MySearchString = "Test"

For ForLoopCounter = 0 To UpperLimitOfArray
  
  FoundSearchStringPosition = InStr(1, MyArray(ForLoopCounter), MySearchString)
  If FoundSearchStringPosition > 0 Then
    
    Call SomeSubToProcessString(Mid(MyArray(ForLoopCounter), FoundSearchStringPosition))
    
  End If
  
Next ForLoopCounter

End Sub

Good Luck

vb5prgrmr 143 Posting Virtuoso

I been searching for days for a sulotion but can't seem to find one.
The coed that I have does not give me an error but it does not save anything on the table either '
Can someone help me find what I'm missing?
this is my coed

Dim mycon As String = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\DEsign.accdb"
        Dim customer As String = "select * from Customer_tbl"
        Dim Notes As String = "select * from Notes_tbl"
        Dim con As New OleDb.OleDbConnection(mycon)
        Dim comCustomer As New OleDb.OleDbCommand(customer, con)
        Dim comdNotes As New OleDb.OleDbCommand(Notes, con)
        Dim Custsql As String = "first name,Last Name"
        Dim Sql As String = "insert into Customer_tbl [b](Custsql )[/b]values '" & txtFirstName.Text & "','" & txtLastName.Text & "')"
        comCustomer = New OleDb.OleDbCommand(Sql, con)
        
        con.Open()
        comCustomer.ExecuteNonQuery()
       comCustomer.Dispose()
        con.Close()

Thank you
Viper

Should be...

Insert Into Table Values (Field_1_Name, Field_2_Name) Values (Field_1_Value, Field_2_Value)

Good Luck

vb5prgrmr 143 Posting Virtuoso

32,000 identifiers, 64Kb limit per proceedure, but it is all limited by the amount of memory you have on the system as per the documentation. Perhaps your pagefile.sys is not large enough or you may need more ram.

Good Luck

Comatose commented: Very Good Information Here! +12
vb5prgrmr 143 Posting Virtuoso

did you check database it is a relational table.Materialrequistionorder with materialrequistiondetail both
table have common field requistion no how should i check both table
at the same time.

Strait from your DB...

SELECT MaterialRequisitionDetail.*, MaterialRequisitionOrder.*
FROM MaterialRequisitionOrder INNER JOIN MaterialRequisitionDetail ON MaterialRequisitionOrder.requsition_no = MaterialRequisitionDetail.requsition_no;

Execute your testing rs and if it fails an if statement like in the earlier post then the records do not exist. However the if statement above will also tell you if it exists.

Good Luck

vb5prgrmr 143 Posting Virtuoso
If rsOrder. BOF = False AND rsOrder.EOF = False AND rsOrder.RecordCount <> 0 Then
  MsgBox "Order Number Exists!"
End If
vb5prgrmr 143 Posting Virtuoso

Try...

Do While Not Eof (FileNumber)
  'do stuff here like reading in your file
Loop

Good Luck

vb5prgrmr 143 Posting Virtuoso

True, but look at the logic originally used. Just trying to get poster to think about their logic...

vb5prgrmr 143 Posting Virtuoso

Don't really know what you're criteria for a valid filename is since you didn't mention the criteria: that might be helpful. But it appears that you 're not allowed to start the name with a number?

Private sub CheckName()

dim strName as String

strName = txtInput

if isNumeric(left(strName, 1)) then
   msgbox "Invalid Name", vbInformation, "String Validation"
Else
   msbBox "Valid Name", vbInformation, "String Validation"
Endif
End sub()

Actually, they want to test the declared variable name, i.e. Dim/Public/Private/Const

However, before I get to that let me suggest I would change your code to test with IsNumeric(Left(...

Now, to answer the origional posters question. Off the top of my head there are only two ways to accomplish what you want. One is to build an Add-In that will check the variables declaration statement and issue a warning if declared wrong.

The second is much easier. Build another program that opens the vb project files (you can read them in notepad to get a head start) and search for the declaration statements of variables. Then check those declarations against the rules you want to apply. Then if you find an incorrectly declared variable you can prompt yourself with whatever information you deem necessary to be able to do a find and replace.

Good Luck

vb5prgrmr 143 Posting Virtuoso

Otherwise known as API. Application Programming Interface. If you have VB 6.0 SP?, then you can access the API view via the vb interface or design environment buy the menu item Add-Ins...

Click on Add-Ins and if you do not see an entry in the sub menu that says API Viewer then goto Add-In Manager.
It takes a moment for it to come up but look for the entry in the list that says VB 6 API Viewer.
Highlight it and then check the checkbox that says Loaded/Unloaded. (My option is to also check the Load On Startup)
Click OK.

Now, go back to the menu item, Add-Ins, and you should now see an entry for API Viewer in the sub menu.
Select it.

In a moment another dialog appears.
Goto File>Load Text File.
The Common dialog open appears and you should see three files listed.
Select WIN32API.TXT
In a moment it should load with API declarations, constants, and types that you can use to extend the functionality of your program.

Good Luck

vb5prgrmr 143 Posting Virtuoso

How is the program choosing the printer? What is the method of printing?

If printer.print mystring then
remove/comment out printer selection code
End If

vb5prgrmr 143 Posting Virtuoso

Select * from your_table where your_field = "Available"

Or am I missing something?

vb5prgrmr 143 Posting Virtuoso

Only a guess, but it looks like you may be comparing an integer with a string. Set a breakpoint on or just before line in question, then user cursor to hover over each value to be evaluated, or use debug window, and check to see if itemcode(i) actually has a value and if Grd.TextMatrix(CLng(row), 1) is returning a string. i.e. "1"

Good Luck

vb5prgrmr 143 Posting Virtuoso

a single update statement will do , why you need a loop for that.

I agree, but original poster is using loop and I am trying to help them with the logic of the loop and as to why only one of multiple records are being updated.

vb5prgrmr 143 Posting Virtuoso

Try something like...

If rs.BOF = False AND rs.EOF = False AND rs.RecordCount <> 0 Then
  rs.MoveFirst
  Do While Not Rs.EOF
    rs.Edit
    rs!pcarrier = "Paid"
    rs.Update
    rs.MoveNext
  Loop
End If
vb5prgrmr 143 Posting Virtuoso

What it is saying in MS-Speak is that the field "Qty" does not exist. Make sure you have it spelled correctly and does exist within the database.

Good Luck

vb5prgrmr 143 Posting Virtuoso

Well, it sounds like you have a plan but to execute it you are going to need to write some code and depending upon which way you go depends upon how much code you will have to write. Now if you trust the user to create a properly formatted SQL string then it should be easy as they would type it into the text box, hit execute (click command button), and you would execute the string, and hopefully be able to handle any errors that may arise.

Now, if you don't trust the user (like me) to properly format a query string, then you have a bit more coding to do. I would suggest that you create a form that contains your db schema on it and allow the user to select the fields that they want in the report. Then you analyze those fields that the user selected and build the query string yourself before you execute it.

Good Luck

vb5prgrmr 143 Posting Virtuoso

Dear Deba what your answer!

dear vb5prgrmr, please clear and details.

Quite simple. Start a new project, add a button, add the code, run program, click button.

Good Luck

vb5prgrmr 143 Posting Virtuoso

ok but wait, wat's the diff? o i no, it's that vb can't use classes rite? not OOP? ic

ps. look at the filename of the attachment, of course it's a joke :)

Man oh man where do I start?

First off, its the syntax that is different between C++ and VB. For example in C it is the parens() that define or contain an if or class where as in VB its a whole differt declaration...

Private MySub()
If ThisIsTrue = True Then
End If
End Sub

Public MyFunction(Arguement1 As String, Arguement2 As Integer) As Byte()
End Function

Now, VB can use classes especially since to add a class it is as simple as a couple of mouse clicks but "Classic VB" or versions 4/5/6 do not support true inheritance and VB is or can be OOP if you know what you are doing and you know what OOP is.

As for your joke, your file has been renamed to http://www.daniweb.com/forums/attachment.php?attachmentid=9400&d=1236124107 so some if not all of us probably don't get it.

vb5prgrmr 143 Posting Virtuoso

i have error to my code in the bold word!

Set rs = New ADODB.Recordset
Set rs1 = New ADODB.Recordset
Set rs2 = New ADODB.Recordset
rs.Open "Select * from temp where pcode='" & txtEdit.Text & "'", cn, adOpenKeyset, adLockPessimistic
rs1.Open "Select * from product where brandname='" & txtEdit.Text & "'", cn, adOpenKeyset, adLockPessimistic
rs2.Open "Select * from Sold", cn, adOpenKeyset, adLockPessimistic
If rs1.RecordCount > 0 Then
[B]rs1.Fields![quantity] = Val(rs1.Fields![quantity]) + Val(rs2.Fields![quantity])[/B]
rs1.Update
End If
If rs.RecordCount > 0 Then
Label7.Caption = Format(Label7.Caption - rs!price * rs!quantity, "00.00")
rs.delete
rs.Requery
MsgBox "Product Successfully Delete", vbInformation
Call grdloader
txtEdit.Visible = False
End If

all i want is if the user delete the record then the quantity of the table in Sold must be + to the quantity table of product. .

This is the third different question you have asked in this thread. You really should (In the future) start a new thread for each question. But to answer your question, with a question.
Does your rs have an edit method?
i.e. rs.edit

Good Luck

vb5prgrmr 143 Posting Virtuoso

how am I going to do that?

For each object you open (cn.open/rs.open) you need to close (rs.close/cn.close). So if you have a global/public connection and any global/public recordsets open, you close, copy, and then reopen if you want to continue on with your program.

Good Luck

vb5prgrmr 143 Posting Virtuoso

If you have the database open via your code or through the access application then you will recieve this error. You need to close all connections to the database prior to trying to copy it.

Good Luck