Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Editting font and adding a quick close on popup window

Status
Not open for further replies.

sandingdude

IS-IT--Management
Jun 26, 2002
109
US
I was wondering how to do 2 things:

1. Edit the font to make it larger on the popup window which displays my duplicates

2. Add a quick close button on the popup window which displays my duplicates

This is my VB Script the guys here were able to help me out with, it compares two tables to check for duplcaites by looking at certain fields. Here is the code:

Function import()
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strsql As String
'SQL string for names that already exist in MAINDB
strsql = "SELECT IMPORTDB.FNAME AS FNAME1, IMPORTDB.LNAME AS LNAME1, " & _
"IMPORTDB.PHONE AS PHONE1, MAINDB.FNAME AS FNAME2, MAINDB.LNAME AS LNAME2, " & _
"MAINDB.PHONE AS PHONE2 " & _
"FROM IMPORTDB INNER JOIN MAINDB ON (IMPORTDB.LNAME = MAINDB.LNAME) WHERE " & _
"(IMPORTDB.FNAME = MAINDB.FNAME) OR (IMPORTDB.FNAME = Left(MAINDB.FNAME,1)) OR (Left(IMPORTDB.FNAME,1) = MAINDB.FNAME);"

Set db = Application.CurrentDb
Set rs = db.OpenRecordset(strsql)
rs.MoveLast
rs.MoveFirst

Do Until rs.EOF

If MsgBox("Name already exists:" & vbCrLf & vbCrLf & _
"IMPORTDB" & vbCrLf & _
rs.Fields("FNAME1").Value & " " & rs.Fields("LNAME1").Value & " " & _
rs.Fields("PHONE1").Value & vbCrLf & vbCrLf & _
"MAINDB" & vbCrLf & _
rs.Fields("FNAME2").Value & " " & rs.Fields("LNAME2").Value & " " & _
rs.Fields("PHONE2").Value & vbCrLf & vbCrLf & _
"Do you want to delete the record in IMPORTDB?", vbYesNo + vbQuestion, _
"Duplicate found") = vbYes Then

'Delete the duplicate record:
DoCmd.RunSQL "DELETE * FROM IMPORTDB WHERE IMPORTDB.FNAME = '" & _
rs.Fields("FNAME1").Value & "' AND IMPORTDB.LNAME = '" & _
rs.Fields("LNAME1").Value & "' AND IMPORTDB.PHONE = '" & _
rs.Fields("PHONE1").Value & "';"

rs.MoveNext

Else:
rs.MoveNext

End If

Loop


End Function

Thank you
 
But you can in a text box on a form. You can also hide the box until you want it and, although I have never done it, you can selectively hide a button so you should be able to simulate what you want with the standard 'out of the box' Access


Mike
 
Thanks for the help guys.

Is there a way to add a button in the msgbox to stop the function and close the msgbox.

Thanks
 
With the cursor inside the MsgBox word in your code, press the F1 key.
 
Thanks PHV

Is there a way to add an actually button that says "STOP"?

Thanks,

Dave
 
Have you tried to play with vbOKCancel or vbYesNoCancel ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks for the help PHV. I am new to all of this stuff. Could you point me in the right direction on using vbOKCancel or vbYesNoCancel.

THanks
 
It is in the help file under MsgBox.

Example:
Code:
Sub test()
Dim lngMsgBoxReturn As Long

lngMsgBoxReturn = MsgBox("Prompt", vbYesNoCancel, "Msg")

Select Case lngMsgBoxReturn

Case 2
    'Code for Cancel
Case 6
    'Code for Yes

Case 7
    'Code for No

Case Else
    'Code for Error
    
End Select

End Sub

You could also use an IF statement instead of Case.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top