Question about Compilers & Programming Tools

1 Answer

About EOF and BOF

Heya, sorry for my bad english language... *_*

i wanna ask about it,

i have the code like this :

-----------------------------------
Private Sub btnCommand_Click(Index As Integer)
Select Case Index

Case 0
If frmPetugasView.Tag = "New" Then

frmPetugasView.Adodc1.Recordset.AddNew

frmPetugasView.Adodc1.Recordset!PetugasID = txtInput(0).Text
frmPetugasView.Adodc1.Recordset!NamaPetugas = txtInput(1).Text
frmPetugasView.Adodc1.Recordset!Keterangan = txtInput(2).Text
frmPetugasView.Adodc1.Recordset.Update

ElseIf frmPetugasView.Tag = "Edit" Then

frmPetugasView.Adodc1.Recordset!PetugasID = txtInput(0).Text
frmPetugasView.Adodc1.Recordset!NamaPetugas = txtInput(1).Text
frmPetugasView.Adodc1.Recordset!Keterangan = txtInput(2).Text
frmPetugasView.Adodc1.Recordset.Update

End If

Case 1

Unload Me
End Select

End Sub
-------------------------------

when i gonna input new data, it show entered data at frmPetugasView

but, when i put same number at primary key then the vb6 show this error code (run time error 80004005)


my teacher show me about using 'if' command for using EOF and BOF for denying same data at primary key, but i lost contact with her for a month.

can someone help me??~

i hope the code is :

option 1 =
when same data entered, input aborted and show dialog with information about aborted process

option 2 =
generate +1 number at last of ID at primary key (i'm using number for primary key)


but i need option 1 better than 2 (i just need that both for my studying... but i need the first one for my project)

Posted by on

1 Answer

  • Level 1:

    An expert who has achieved level 1.

    Corporal:

    An expert that hasĀ over 10 points.

    Mayor:

    An expert whose answer gotĀ voted for 2 times.

    Problem Solver:

    An expert who has answered 5 questions.

  • Contributor
  • 10 Answers

Hello Gugukandmiaw
You do not have to use the elseif statement. Maybe this will work.
Greetings Fred Roubos.


With frmPetugasView.Adodc1.Recordset
If frmPetugasView.Tag = "New" Then
.AddNew
!PetugasID = txtInput(0).Text
!NamaPetugas = txtInput(1).Text
!Keterangan = txtInput(2).Text
.Update
End if

If frmPetugasView.Tag = "Edit" Then
!PetugasID = txtInput(0).Text
!NamaPetugas = txtInput(1).Text
!Keterangan = txtInput(2).Text
.Update
End If
End With

Posted on Dec 24, 2008

Add Your Answer

Uploading: 0%

my-video-file.mp4

Complete. Click "Add" to insert your video. Add

×

Loading...
Loading...

Related Questions:

1 Answer

My laptop with windows 7 is start up with a black screen and ask me wath operation sistem i want to strart windows 7 an 2 more but this 2 more no starting only w 7 this problems came before i instal a...


hi jose,

what is the problem exactly? this 2nd operation system appearance? you want to get rid of this black screen and go directly to win 7, correct?

thank you,
dim

Mar 22, 2011 | HP Compilers & Programming Tools

1 Answer

Visual foxpro code for how to search


If the search field is not indexed:
LOCATE FOR <fld_search> <condition> [CONTINUE]
Example: * View customers with outstanding bills USE CUST LOCATE FOR cBillDue > 0 DISPLAY OFF cCustId, cBillDue DO WHILE !EOF() CONTINUE IF NOT EOF() DISPLAY OFF cCustId, cBillDue ENDIF ENDDO
If the search field is indexed:SET ORDER TO TAG <index_tag> SEEK <value>
Example:* Locate customer '0025' USE CUST SET ORDER TO TAG custid SEEK '0025' IF FOUND() DISPLAY ELSE = MESSAGEBOX('CUSTOMER 0025 was not found') ENDIF
Best regards

Sep 20, 2010 | Microsoft Visual Basic Enterprise Edition...

1 Answer

What is java programming language?


http://en.wikipedia.org/wiki/Java_(programming_language)
In order to understand the difference between high-level programming languages and lower level languages you might have to have a deeper knowledge of computers than you currently have, although I can try to the best of my ability to explain it simply.
Lower level programming languages are more directly related to the actual machine language that the computer ends up reading in the end. Higher level programming languages are less representative of the actual machine code, and as a result may require either a more advanced compiler or may require being compiled several times. Generally higher-level programming languages are easier for the user to write in than lower-level languages.

Nov 11, 2009 | Sun Compilers & Programming Tools

1 Answer

I have a Dell 924 printer and the language is set on ''some'' kind of other language. How do I reset it to English?


Resetting the Language on Your Printer
If you need to change the default language used on the operator panel, complete the following
steps:
1) Press the Power button to turn off the printer.
2) Press the Power button and the up arrow button simultaneously.
3) When the language settings appear, press the Arrow buttons to scroll to your
language.
4) Press the Menu button to select your language.

Thanks for using Fixya.

PS. For reference, here is a link to your User Manual:

Dell 924 Manual

Jul 02, 2009 | Compilers & Programming Tools

1 Answer

How do copy a table from an access database in one folder to another access database in another folder through visual basic code


Simple method Open both tables (or create second) and copy each record from source to target through 'do while not eof' or 'for each' syntax.

Second solution create link in target DB for first table, and use SELECT INTO statment in SQL.

Mar 02, 2009 | Microsoft Visual Basic 6.0 for PC

1 Answer

Book mark property of recordset (ado)


The bookmark property of a recordset lets you store and retrieve the location of a record in a variable so that you can move directly to it in your recordset without having to use a query to extract that record. Like you can just move forward a record and back a record, or move to the first or last records without a quesry statement, you can move to the bookmarked record directly in code.

Here's a good VB example that compares the bookmakr property to the movefirst and movelast properties. This should answer your question, and please rate my answer.

'BeginBOFVB 'To integrate this code 'replace the data source and initial catalog values 'in the connection string Public Sub Main() On Error GoTo ErrorHandler 'recordset and connection variables Dim Cnxn As ADODB.Connection Dim rstPublishers As ADODB.Recordset Dim strCnxn As String Dim strSQLPubs As String 'record variables Dim strMessage As String Dim intCommand As Integer Dim varBookmark As Variant ' open connection Set Cnxn = New ADODB.Connection strCnxn = "Provider='sqloledb';Data Source='MySqlServer';" & _ "Initial Catalog='Pubs';Integrated Security='SSPI';" Cnxn.Open strCnxn ' Open recordset and use client cursor ' to enable AbsolutePosition property Set rstPublishers = New ADODB.Recordset strSQLPubs = "SELECT pub_id, pub_name FROM publishers ORDER BY pub_name" rstPublishers.Open strSQLPubs, strCnxn, adUseClient, adOpenStatic, adCmdText rstPublishers.MoveFirst Do Until rstPublishers.EOF ' Display information about current record ' and get user input strMessage = "Publisher: " & rstPublishers!pub_name & _ vbCr & "(record " & rstPublishers.AbsolutePosition & _ " of " & rstPublishers.RecordCount & ")" & vbCr & vbCr & _ "Enter command:" & vbCr & _ "[1 - next / 2 - previous /" & vbCr & _ "3 - set bookmark / 4 - go to bookmark]" intCommand = Val(InputBox(strMessage)) ' Check user input Select Case intCommand Case 1 ' Move forward trapping for EOF rstPublishers.MoveNext If rstPublishers.EOF Then MsgBox "Moving past the last record." & _ vbCr & "Try again." rstPublishers.MoveLast End If Case 2 ' Move backward trapping for BOF rstPublishers.MovePrevious If rstPublishers.BOF Then MsgBox "Moving past the first record." & _ vbCr & "Try again." rstPublishers.MoveFirst End If Case 3 ' Store the bookmark of the current record varBookmark = rstPublishers.Bookmark Case 4 ' Go to the record indicated by the stored bookmark If IsEmpty(varBookmark) Then MsgBox "No Bookmark set!" Else rstPublishers.Bookmark = varBookmark End If Case Else Exit Do End Select Loop ' clean up rstPublishers.Close Cnxn.Close Set rstPublishers = Nothing Set Cnxn = Nothing Exit Sub ErrorHandler: ' clean up If Not rstPublishers Is Nothing Then If rstPublishers.State = adStateOpen Then rstPublishers.Close End If Set rstPublishers = Nothing If Not Cnxn Is Nothing Then If Cnxn.State = adStateOpen Then Cnxn.Close End If Set Cnxn = Nothing If Err <> 0 Then MsgBox Err.Source & "-->" & Err.Description, , "Error" End If End Sub 'EndBOFVB

Jan 07, 2009 | Microsoft Visual Basic 6.0 for PC

1 Answer

C PROGRAM


#include <stdio.h>
int main ()
{
FILE * pFile;
int c;
int n = 0;
pFile=fopen ("test.txt","r");
if (pFile==NULL) perror ("Error opening file");
else
{
do { //DO
c = fgetc (pFile);
if (c == '$') n++;
} //DO
while (c != EOF);
fclose (pFile);
printf ("File contains %d$.\n",n);
}
return 0;
}

Aug 31, 2008 | Compilers & Programming Tools

1 Answer

Vb 6.0 ado connection without ado control moving next record


I see 2 problems with your code.

1) Each time you call cmdnext_Click, you're reopening the database. Each time you do that, you start at the beginning of the file. You need to have the database opened once, somewhere else in your program. Be sure that the record set is visible from this sub.

2) In order to use the "Next" function, you need a loop like this

'test for no records
IF REC.BOF and REC.EOF then
msgbox "No Records Found"
exit sub
end if

IF NOT REC.EOF then
REC.MoveNext
(display your fields)
END IF


Again, this will only work if your database is opened outside of the cmdNext_Click routine.

Jul 08, 2008 | Microsoft Compilers & Programming Tools

2 Answers

The sims 2 pc


The sims themselves in the game don't speak any real language, just sounds with balloons that explain what they want.

Jan 05, 2008 | Compilers & Programming Tools

5 Answers

English Version of TG Dream Combo M4100 Printer's Driver


give me more info of you printer full name version etc

Sep 19, 2007 | Compilers & Programming Tools

Not finding what you are looking for?
Compilers & Programming Tools Logo

Related Topics:

136 people viewed this question

Ask a Question

Usually answered in minutes!

Top Compilers & Programming Tools Experts

Robin Hill
Robin Hill

Level 3 Expert

1251 Answers

Les Dickinson
Les Dickinson

Level 3 Expert

18297 Answers

Florin

Level 3 Expert

733 Answers

Are you a Compiler and Programming Tool Expert? Answer questions, earn points and help others

Answer questions

Manuals & User Guides

Loading...